Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Incompatibility when used with esm loader #22

Closed
rwjblue opened this issue Aug 19, 2019 · 2 comments
Closed

Incompatibility when used with esm loader #22

rwjblue opened this issue Aug 19, 2019 · 2 comments

Comments

@rwjblue
Copy link
Contributor

rwjblue commented Aug 19, 2019

When heimdall-fs-monitor is used within a process using standard-things/esm the following error occurs:

TypeError: Function.prototype.apply was called on undefined, which is a undefined and not a function
    at $o (/home/travis/build/ember-cli/ember-cli/tmp/node-FGpJBujF.tmp/node_modules/esm/esm.js:1:224377)
    at xu (/home/travis/build/ember-cli/ember-cli/tmp/node-FGpJBujF.tmp/node_modules/esm/esm.js:1:226413)
    at wu (/home/travis/build/ember-cli/ember-cli/tmp/node-FGpJBujF.tmp/node_modules/esm/esm.js:1:227391)
    at Eu (/home/travis/build/ember-cli/ember-cli/tmp/node-FGpJBujF.tmp/node_modules/esm/esm.js:1:227999)
    at Module.<anonymous> (/home/travis/build/ember-cli/ember-cli/tmp/node-FGpJBujF.tmp/node_modules/esm/esm.js:1:295976)
    at n (/home/travis/build/ember-cli/ember-cli/tmp/node-FGpJBujF.tmp/node_modules/esm/esm.js:1:279589)
    at getFeatures (/home/travis/build/ember-cli/ember-cli/tmp/node-FGpJBujF.tmp/node_modules/@ember-data/-build-infra/src/features.js:5:33)
    at Object.<anonymous> (/home/travis/build/ember-cli/ember-cli/tmp/node-FGpJBujF.tmp/node_modules/@ember-data/-build-infra/src/features.js:31:18)

This is affecting all ember-cli users that have instrumentation enabled (BROCCOLI_VIZ=1 / EMBER_CLI_INSTRUMENTATION=1 / .ember-cli config) and are also using ember-data@3.12.0 (where the esm usage was introduced).

This is currently causing ember-cli's own CI to fail (release, beta, and master) as of the date that ember-data@3.12.0 was published (2019-08-06).

@rwjblue
Copy link
Contributor Author

rwjblue commented Aug 19, 2019

The issue here seems to be that when we replace all functions on fs we also replace things that are "functions" but really are classes. The things listed as classes on fs (based on the docs) are:

  • fs.Dirent
  • fs.FSWatcher
  • fs.ReadString
  • fs.Stats
  • fs.WriteStream
  • fs.FileHandle

Then when esm attempts to do:

let isFile = fs.Stats.prototype.isFile;

The fs.Stats class has been replaced by our wrapped function and no longer has the same prototype, this is what ultimately causes the error message above (when esm calls Reflect.apply(isFile, statsObject, [])).

@rwjblue
Copy link
Contributor Author

rwjblue commented Aug 19, 2019

Fixed by #23 and released in v0.2.3.

@rwjblue rwjblue closed this as completed Aug 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant