Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new Buffer() -> TypeError: Cannot read properties of null (reading '0') -> starting on node 20.15 #3872

Closed
brunoargolo opened this issue Aug 9, 2024 · 3 comments

Comments

@brunoargolo
Copy link

When using esbuild to transpile/bundle specific code on node 20.15 it triggers a runtime error.
The same code transpiled/executed with esbuild on 20.14 works fine.
If we bypass esbuild and run the code directly on 20.15 it also works.

Minimal repo to reproduce: https://github.com/brunoargolo/esbuild-node20.15-exceljs-bug/tree/master

Code:
index.js

import exceljs from 'exceljs';

export const handler = () => {
  const workbook = new exceljs.stream.xlsx.WorkbookWriter({});
  console.log('Success!!!')
}

test.js

import { handler } from "./dist/index.js";
await handler();

esbuild.js is inside repo listed above

volta pin [email protected] && node esbuild.js && node test.js

Error:

node:internal/util:508
        filename[0] !== '/' &&
                ^

TypeError: Cannot read properties of null (reading '0')
    at isInsideNodeModules (node:internal/util:508:17)
    at showFlaggedDeprecation (node:buffer:178:8)
    at new Buffer (node:buffer:266:3)
    at utils.normalizeInputSource (file:///Users/dev/exceljsbug/dist/index.js:44519:16)
    at Archiver.append (file:///Users/dev/exceljsbug/dist/index.js:44932:21)
    at file:///Users/dev/exceljsbug/dist/index.js:49153:20
    at new Promise (<anonymous>)
    at WorkbookWriter.addThemes (file:///Users/dev/exceljsbug/dist/index.js:49152:16)
    at new WorkbookWriter (file:///Users/dev/exceljsbug/dist/index.js:49040:42)
    at handler (file:///Users/dev/exceljsbug/dist/index.js:64169:20)
    at file:///Users/dev/exceljsbug/test.js:2:7
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)
volta pin [email protected] && node esbuild.js && node test.js
success!!!
@hyrious
Copy link

hyrious commented Aug 10, 2024

This seems a Node.js bug: nodejs/node#54296
The test-straight.js works because it simply does not hit the preconditions of the issue: The new Buffer() deprecation check only happens outside of node_modules. The straight way of calling exceljs obviously leaves the code containing new Buffer() inside node_modules. While dist/index.js is outside of it.

@brunoargolo
Copy link
Author

Thanks @hyrious , agreed. Closing the bug.

@brunoargolo
Copy link
Author

This is now addressed on node 20.17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants