Description
Version
v22.2.0
Platform
Any platform
Subsystem
buffer
What steps will reproduce the bug?
Reproducing this requires code that uses new Buffer()
with wasm in the stacktrace somewhere.
I ran into this using zstd-codec which calls new Buffer()
internally in various places. This can be reproduced with:
npm install zstd-codec
- Run code using the wasm implementation, e.g:
require('zstd-codec').ZstdCodec.run(zstd => { new zstd.Simple().compress(Buffer.from([])) })
How often does it reproduce? Is there a required condition?
Fails every time with:
Uncaught TypeError: Cannot read properties of undefined (reading '0')
at isInsideNodeModules (node:internal/util:511:17)
at showFlaggedDeprecation (node:buffer:178:8)
at new Buffer (node:buffer:266:3)
at emval_allocator_3 (eval at craftEmvalAllocator (/tmp/tmp.ujfY2uo6b7/node_modules/zstd-codec/lib/zstd-codec-binding-wasm.js:8:951735), <anonymous>:13:11)
at __emval_new (/tmp/tmp.ujfY2uo6b7/node_modules/zstd-codec/lib/zstd-codec-binding-wasm.js:8:952078)
at wasm://wasm/0025c056:wasm-function[50]:0x10d2
at wasm://wasm/0025c056:wasm-function[87]:0x23c1
What is the expected behavior? Why is that the expected behavior?
This should not fail (and does not, for Node < 22.2.0). In Node v22.1.0 the code snippet above just runs happily without errors.
(Of course, libraries should also update and avoid using deprecated APIs, but it would be good if the deprecation warning itself didn't break anything in the meantime)
What do you see instead?
Fails every time
Additional information
I'm fairly sure that this is due to #52147 (cc @Uzlopak) which changed isInsideNodeModules
to check filename[0]
for every stack frame.
I'm not really familiar with wasm internals at all, but based on this error I think it looks pretty clear that filename === undefined
for wasm stack frames, and so filename[0]
crashes for any wasm code that calls that method.
Activity