meteor / reify

Enable ECMAScript 2015 modules in Node today. No caveats. Full stop.
MIT License
6 stars 3 forks source link

TLA not detected for a top level variable that awaits a function call #9

Closed perbergland closed 2 months ago

perbergland commented 2 months ago

https://github.com/meteor/meteor/issues/12986 is still not resolved for me in 0.25.2 (meteor 3.0.1).

This code does NOT trigger TLA:

export const AuditLog = await createCollectionAsync<AuditLogEntry>("auditlog", {
  indices,
  schema: getAuditLogSchema(),
});

The workaround to add an await 0 in the file still works.

await 0; // temp TLA detection fix
export const AuditLog = await createCollectionAsync<AuditLogEntry>("auditlog", {
  indices,
  schema: getAuditLogSchema(),
});
perbergland commented 2 months ago

I tried replacing the contents of test/tla/exported-declaration.js with my old test case

const asyncInitializer = async () => 'value';

export const test = await asyncInitializer();

but the test is still green…

perbergland commented 2 months ago

Emitted code (in programs/server/app/app.js):

Without workaround:

    const AuditLog = await createCollectionAsync("auditlog", {
      indices,
      schema: getAuditLogSchema()
    });

    __reify_async_result__();
  } catch (_reifyError) {
    return __reify_async_result__(_reifyError);
  }
  __reify_async_result__()
}, {
  self: this,
  async: false
});

with workaround:

    await 0;
    const AuditLog = await createCollectionAsync("auditlog", {
      indices,
      schema: getAuditLogSchema()
    });

    __reify_async_result__();
  } catch (_reifyError) {
    return __reify_async_result__(_reifyError);
  }
  __reify_async_result__()
}, {
  self: this,
  async: true
});
perbergland commented 2 months ago

Ping @leonardoventurini I can’t figure this one out, would appreciate help if you have time

perbergland commented 2 months ago

The problem does not seem to be in this lib but in the combination of reify, babel and meteor-tools and package versioning