Today I noticed that I can no longer build my app locally using ember build -prod. CI builds fine and ember server works without issues as well. This is the error I am seeing:
Build Error (Filter) in assets/auto-import-fastboot-4c714e85e4221f8fc7a6c5c479aab887.js
The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Node
Stack Trace and Error Report: /var/folders/yt/kw3pd9l52sd9bbpjrlpm47rm0000gn/T/error.dump.0037d8464d97591f58ec1a4589a7e0b7.log
This is the error description from error.dump.0037d8464d97591f58ec1a4589a7e0b7.log
ERROR Summary:
- broccoliBuilderErrorStack: TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Node
at Object.writeFileSync (fs.js:1409:5)
at asyncOutputFilteredFile (/Users/steve/code/myapp/myapp/node_modules/broccoli-filter/index.js:173:12)
at tryCatch (/Users/steve/code/myapp/myapp/node_modules/broccoli-filter/node_modules/rsvp/dist/rsvp.js:525:12)
at invokeCallback (/Users/steve/code/myapp/myapp/node_modules/broccoli-filter/node_modules/rsvp/dist/rsvp.js:538:13)
at /Users/steve/code/myapp/myapp/node_modules/broccoli-filter/node_modules/rsvp/dist/rsvp.js:606:14
at flush (/Users/steve/code/myapp/myapp/node_modules/broccoli-filter/node_modules/rsvp/dist/rsvp.js:2415:5)
at processTicksAndRejections (internal/process/task_queues.js:75:11)
- code: [undefined]
- codeFrame: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Node
- errorMessage: assets/auto-import-fastboot-4c714e85e4221f8fc7a6c5c479aab887.js: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Node
in /var/folders/yt/kw3pd9l52sd9bbpjrlpm47rm0000gn/T/broccoli-39164X71aTw4kXt5G/out-666-broccoli_persistent_filter_fastboot_manifest_rewrite_brocco
at Filter
- errorType: Build Error
- location:
- column: [undefined]
- file: assets/auto-import-fastboot-4c714e85e4221f8fc7a6c5c479aab887.js
- line: [undefined]
- treeDir: /var/folders/yt/kw3pd9l52sd9bbpjrlpm47rm0000gn/T/broccoli-39164X71aTw4kXt5G/out-666-broccoli_persistent_filter_fastboot_manifest_rewrite_brocco
- message: assets/auto-import-fastboot-4c714e85e4221f8fc7a6c5c479aab887.js: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Node
in /var/folders/yt/kw3pd9l52sd9bbpjrlpm47rm0000gn/T/broccoli-39164X71aTw4kXt5G/out-666-broccoli_persistent_filter_fastboot_manifest_rewrite_brocco
at Filter
- name: Error
- nodeAnnotation: [undefined]
- nodeName: Filter
- originalErrorMessage: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Node
- stack: TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Node
at Object.writeFileSync (fs.js:1409:5)
at asyncOutputFilteredFile (/Users/steve/code/myapp/myapp/node_modules/broccoli-filter/index.js:173:12)
at tryCatch (/Users/steve/code/myapp/myapp/node_modules/broccoli-filter/node_modules/rsvp/dist/rsvp.js:525:12)
at invokeCallback (/Users/steve/code/myapp/myapp/node_modules/broccoli-filter/node_modules/rsvp/dist/rsvp.js:538:13)
at /Users/steve/code/myapp/myapp/node_modules/broccoli-filter/node_modules/rsvp/dist/rsvp.js:606:14
at flush (/Users/steve/code/myapp/myapp/node_modules/broccoli-filter/node_modules/rsvp/dist/rsvp.js:2415:5)
at processTicksAndRejections (internal/process/task_queues.js:75:11)
The only file that starts with auto-import-fastboot-* is
I am not sure if this is a fastboot or auto-import related error. And I don’t have a clue why I am starting to see this locally, but not on CI. Any ideas what might be going on?
Finally found something, as CI started to fail with a different error (which luckily contained a useable stacktrace). I am using broccoli-strip-debug and something causes it to fail. If I remove it, my build runs through again.
ember-cli-build.js:
let tree = app.toTree();
if (app.env === 'production') {
console.log('stripping debug statements...');
let stripDebug = require('broccoli-strip-debug');
tree = new stripDebug(tree);
console.log('done stripping debug statements...');
}
What’s quite strange to me is that the log statements are printed at the beginning of the build, however, the build fails after doing a lot of other stuff.
That’s because broccoli doesn’t work synchronously. new stripDebug only sets up the transform, it doesn’t actually do any work until later when broccoli decides to rebuild.
I would put a debugger statement in broccoli-strip-debug’s processString() method and see what’s going on there. It seems like it’s not returning a string, which breaks broccoli-filter.
But also, I think an easier way to get this feature is via a babel plugin like remove-console, because your code is already going through babel anyway. It would like look this in ember-cli-build.js:
let app = new EmberApp({
babel: {
plugins: [
require.resolve('babel-plugin-transform-remove-console')
]
}
});
Ah, thanks so much for the clarification. That makes sense. I just started to replace all console.log references with ember debug statements. It’s not that many statements, so that’s ok and it’s easy to find and replace. Though, I’ll lose the different log levels - but maybe even that will be ok. If not, I am going back to console for warn and error and try to strip them with babel. Thanks again. I just realise I should set some time aside to check out how ember is built somewhen.
Just glad to see broccoli-strip-debug go, as I was also having issues getting it to work with embroider, when I last tried it.
I remember I recently read about a fastboot app which suddenly had the same error. And it turns out it’s the same issue. Modifying targets to use 'Chrome >= 78' solved the fastboot issue.
So this issue is that you need to add node: 'current' to your targets file. Its something that I’m working on fixing the default behaviour for ember-cli-fastboot at the moment.