ember-cli / ember-cli

The Ember.js command line utility.

Home Page:https://cli.emberjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ember build --watch fails with '[NodeWrapper:4 /path/to/some/folder] is not a SourceNode' when the app name contains 'ember-data' anywhere

mansona opened this issue Β· comments

Output from `ember version --verbose && npm --version && pnpm --version` ember-cli: 5.2.1 node: 16.18.1 v8: 9.4.146.26-node.22 uv: 1.43.0 zlib: 1.2.11 brotli: 1.0.9 ares: 1.18.1 modules: 93 nghttp2: 1.47.0 napi: 8 llhttp: 6.0.10 openssl: 1.1.1q+quic cldr: 41.0 icu: 71.1 tz: 2022b unicode: 14.0 ngtcp2: 0.8.1 nghttp3: 0.7.0 os: darwin x64 8.19.2 8.6.9

The error I'm getting is [NodeWrapper:4 /Users/mansona/temp/ember-data-watch-problem/node_modules/ember-cli-test-loader/test-support] is not a SourceNode

Full error log
=================================================================================

ENV Summary:

  TIME: Mon Sep 04 2023 16:36:40 GMT+0100 (Irish Standard Time)
  TITLE: ember
  ARGV:
  - /Users/mansona/.nvm/versions/node/v16.18.1/bin/node
  - /opt/homebrew/bin/ember
  - build
  - --watch
  EXEC_PATH: /Users/mansona/.nvm/versions/node/v16.18.1/bin/node
  TMPDIR: /var/folders/r5/bw5frvnn5k794hk62w3vp7km0000gn/T
  SHELL: /bin/zsh
  PATH:
  - /Users/mansona/.nvm/versions/node/v16.18.1/bin
  - /Users/mansona/.rvm/gems/ruby-2.6.3/bin
  - /Users/mansona/.rvm/gems/ruby-2.6.3@global/bin
  - /Users/mansona/.rvm/rubies/ruby-2.6.3/bin
  - /Users/mansona/Library/pnpm
  - /Users/mansona/.pyenv/shims
  - /Users/mansona/Library/Android/sdk/platform-tools
  - /Users/mansona/Library/Android/sdk/tools
  - /Users/mansona/google-cloud-sdk/bin
  - /opt/homebrew/bin
  - /opt/homebrew/sbin
  - /usr/local/bin
  - /System/Cryptexes/App/usr/bin
  - /usr/bin
  - /bin
  - /usr/sbin
  - /sbin
  - /usr/local/go/bin
  - /usr/local/MacGPG2/bin
  - /Library/Apple/usr/bin
  - /Library/Frameworks/Mono.framework/Versions/Current/Commands
  - /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin
  - /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin
  - /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
  - /Users/mansona/.cargo/bin
  - /Users/mansona/.rvm/bin
  - /Users/mansona/go/bin
  PLATFORM: darwin x64
  FREEMEM: 296460288
  TOTALMEM: 34359738368
  UPTIME: 2356918
  LOADAVG: 10.68115234375,9.1552734375,9.62939453125
  CPUS:
  - Apple M1 Pro - 24
  - Apple M1 Pro - 24
  - Apple M1 Pro - 24
  - Apple M1 Pro - 24
  - Apple M1 Pro - 24
  - Apple M1 Pro - 24
  - Apple M1 Pro - 24
  - Apple M1 Pro - 24
  - Apple M1 Pro - 24
  - Apple M1 Pro - 24
  ENDIANNESS: LE
  VERSIONS:
  - ares: 1.18.1
  - brotli: 1.0.9
  - cldr: 41.0
  - icu: 71.1
  - llhttp: 6.0.10
  - modules: 93
  - napi: 8
  - nghttp2: 1.47.0
  - nghttp3: 0.7.0
  - ngtcp2: 0.8.1
  - node: 16.18.1
  - openssl: 1.1.1q+quic
  - tz: 2022b
  - unicode: 14.0
  - uv: 1.43.0
  - v8: 9.4.146.26-node.22
  - zlib: 1.2.11

ERROR Summary:

  - broccoliBuilderErrorStack: [undefined]
  - code: [undefined]
  - codeFrame: [undefined]
  - errorMessage: [NodeWrapper:4 /Users/mansona/temp/ember-data-watch-problem/node_modules/ember-cli-test-loader/test-support] is not a SourceNode
  - errorType: [undefined]
  - location:
    - column: [undefined]
    - file: [undefined]
    - line: [undefined]
  - message: [NodeWrapper:4 /Users/mansona/temp/ember-data-watch-problem/node_modules/ember-cli-test-loader/test-support] is not a SourceNode
  - name: Error
  - nodeAnnotation: [undefined]
  - nodeName: [undefined]
  - originalErrorMessage: [undefined]
  - stack: Error: [NodeWrapper:4 /Users/mansona/temp/ember-data-watch-problem/node_modules/ember-cli-test-loader/test-support] is not a SourceNode
    at new WatcherAdapter (/Users/mansona/temp/ember-data-watch-problem/node_modules/broccoli/dist/watcher_adapter.js:20:23)
    at new Watcher (/Users/mansona/temp/ember-data-watch-problem/node_modules/broccoli/dist/watcher.js:24:17)
    at Watcher.constructBroccoliWatcher (/Users/mansona/temp/ember-data-watch-problem/node_modules/ember-cli/lib/models/watcher.js:62:19)
    at async Watcher.setupBroccoliWatcher (/Users/mansona/temp/ember-data-watch-problem/node_modules/ember-cli/lib/models/watcher.js:43:37)
    at async Function.build (/Users/mansona/temp/ember-data-watch-problem/node_modules/ember-cli/lib/models/watcher.js:31:5)
    at async BuildWatchTask.run (/Users/mansona/temp/ember-data-watch-problem/node_modules/ember-cli/lib/tasks/build-watch.js:39:9)
    at async Class.run (/Users/mansona/temp/ember-data-watch-problem/node_modules/ember-cli/lib/commands/build.js:29:5)
    at async /Users/mansona/temp/ember-data-watch-problem/node_modules/ember-cli/lib/cli/cli.js:197:32
    at async CLI.run (/Users/mansona/temp/ember-data-watch-problem/node_modules/ember-cli/lib/cli/cli.js:244:14)
    at async module.exports (/Users/mansona/temp/ember-data-watch-problem/node_modules/ember-cli/lib/cli/index.js:145:12)

=================================================================================

Steps to reproduce

  • EMBER_CLI_PNPM=true npx ember-cli@latest new --pnpm ember-data-watch-problem
  • cd ember-data-watch-problem
  • ember build --watch
  • πŸ’₯

Note: I tried it in both pnpm and npm and it had the same issue

Initial debugging

I tracked the issue down to this line: https://github.com/broccolijs/broccoli/blob/master/lib/watcher_adapter.ts#L29 (or rather the js built file that corresponds to that line) and in the debugger the value of node.constructor.name is SourceNodeWrapper

Does this happen with ember-cli 5.1?
(Or any versions in between?)

oooo intersting... it does not happen in ember@5.1:

  • EMBER_CLI_PNPM=true npx ember-cli@5.1 new --pnpm ember-5-1
  • ember build --watch
  • πŸŽ‰

I also tested it in ember@5.2.0 explicitly and that worked:

  • EMBER_CLI_PNPM=true npx ember-cli@5.2.0 new --pnpm ember-5-2-0
  • cd ember-5-2-0
  • ember build --watch
  • πŸŽ‰ it worked

I think it's the same issue as this one: emberjs/data#8606

It seems related to the folder name. If it includes ember-data it throws that error. I haven't looked into it myself, just noticed the folder name also included ember-data in the original post.

😫 here's me thinking it's an exact version problem and it's because of the name of the app 😫

I don't know what to do with this issue now πŸ€” I would think that we should close it since it's clearly something to do with ember-data's strange build system, but it's a build issue that people will feel with a newly generated app from ember-cli so I kinda want to leave this open πŸ€”

I suspected it was something to do with rollup because looking at the file it's clearly been put through a rollup process (rollup loves to add _1 to all the imported variables) so it is likely that it's because of ember-data's strange rollup build thingy leaking out 😞

It seems to be a broccoli issue, actually. This issue was mentioned in the other thread: broccolijs/broccoli#503

Keeping it open for visibility makes sense I think πŸ‘.

I'm not sure I would agree that it's a broccoli issue if it goes away when you remove the ember-data dependency πŸ˜‚ the fact that broccoli is doing an instance of check just means that it relies on all parts of the app discovering the exact same SourceNodeWrapper class when importing it. It's possible that ember-data's internal rollup is doing something odd and creating a second copy somehow which would then fail the instance of check.

It's true that we could work around this by changing broccoli's implementation to use node.constructor.name to check if the node is a SorceNodeWrapper but that's brittle in a different way

@mansona EmberData does not do anything custom in its build at this point. My suspicion is broccoli or some associated ember-cli dep has a loose check somewhere that more or less amounts to name.startsWith(addonName)

Anyone got a solution or workaround for this? I've created a fork of:

https://www.npmjs.com/package/ember-data-hal-9000

and I'm bumping it to 5.4, but getting the mentioned errors.

Edit: I guess the only workaround is to change the name of the package for my fork...