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

callSite.getFileName is not a function #50

Open
loynoir opened this issue Nov 6, 2022 · 10 comments
Open

callSite.getFileName is not a function #50

loynoir opened this issue Nov 6, 2022 · 10 comments
Assignees

Comments

@loynoir
Copy link

loynoir commented Nov 6, 2022

$ node --frozen-intrinsics
> require('depd')('http-errors')('non-error status code; use only 4xx or 5xx status codes')
Uncaught:
TypeError <Object <Object <[Object: null prototype] {}>>>: callSite.getFileName is not a function
@dougwilson
Copy link
Owner

dougwilson commented Nov 6, 2022

Hi @loynoir thanks for reporting! As far as I am aware, all versions of Node.js have that function, and also the error looks weird and there is no stack trace. Can you help by providing the following information?

  1. Version of Node.js you are running this module on
  2. Version of this module you are running

Thank you!

@loynoir
Copy link
Author

loynoir commented Nov 6, 2022

"depd": "^2.0.0"
$ node --frozen-intrinsics
Welcome to Node.js v16.18.0.
> require('depd')('http-errors')('non-error status code; use only 4xx or 5xx status codes')
Uncaught:
TypeError <Object <Object <[Object: null prototype] {}>>>: callSite.getFileName is not a function
    at callSiteLocation (/path/to/node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js:268:23)
    at depd (/path/to/node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js:109:14)
$ node --frozen-intrinsics
Welcome to Node.js v18.12.0.
> require('depd')('http-errors')('non-error status code; use only 4xx or 5xx status codes')
Uncaught:
TypeError <Object <Object <[Object: null prototype] {}>>>: callSite.getFileName is not a function
    at callSiteLocation (/path/to/node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js:268:23)
    at depd (/path/to/node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js:109:14)

@dougwilson
Copy link
Owner

Oh, I see now, it's something to do with --frozen-intrinsics (https://nodejs.org/dist/latest-v18.x/docs/api/cli.html#--frozen-intrinsics). It seems that is experimental and your output should be having an experimental warning. Weird that you're not seeing that warning. But I can look into what it would take to support that environment, though since it's experimental not sure on what I can promise around that, as experimental features of Node.js change often which makes them hard to support correctly.

@loynoir
Copy link
Author

loynoir commented Nov 6, 2022

Ah I delete that warning, I guess easier to read.

$ pnpm node --frozen-intrinsics
(node:6252) ExperimentalWarning: The --frozen-intrinsics flag is experimental
(Use `node --trace-warnings ...` to show where the warning was created)
Welcome to Node.js v18.12.0.
Type ".help" for more information.
> require('depd')('http-errors')('non-error status code; use only 4xx or 5xx status codes')
Uncaught:
TypeError <Object <Object <[Object: null prototype] {}>>>: callSite.getFileName is not a function
    at callSiteLocation (/path/to/node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js:268:23)
    at depd (/path/to/node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js:109:14)

@dougwilson
Copy link
Owner

dougwilson commented Nov 6, 2022

Ah. But yea, as the Node.js docs state:

Code may break under this flag.

I'll take a look into what it would take to support that and see how the flag varies across the Node.js versions released so far to get a hint at future direction of the experimental feature too. For now, I would suggest not using that feature if you want to use this module.

@loynoir
Copy link
Author

loynoir commented Nov 6, 2022

@dougwilson
Copy link
Owner

I'm not sure what that link means.

@loynoir
Copy link
Author

loynoir commented Nov 6, 2022

There is nodejs contributor suggestion, maybe, to use that flag to protect prototype pollution instead of crashed Object.freeze(NODE_GLOBAL_AND_ITS_PROTOTYPE).

@dougwilson
Copy link
Owner

Ah. But yea, like I pointed out, the Node.js documentation for --frozen-intrinsics (https://nodejs.org/dist/latest-v18.x/docs/api/cli.html#--frozen-intrinsics) specifically states the following:

Code may break under this flag.

And it looks like indeed, this code does break under that flag. Node.js seems well aware you're going to run into issues with that experimental feature. Like I said, I will look into what it would take to work with that flag, if it is even possible. But it is experimental and as Node.js states:

Stability: 1 - Experimental. The feature is not subject to semantic versioning rules. Non-backward compatible changes or removal may occur in any future release. Use of the feature is not recommended in production environments.

I will try my best to support it, but supporting experimental features are hard by their nature of random changes without concern for breaking things.

@loynoir
Copy link
Author

loynoir commented Nov 9, 2022

Ah, have a look where is the first place goes wrong when using that flag.

Error.prepareStackTrace = prepareObjectStackTrace

So, this seems related to #16

with --frozen-intrinsics

> Error.prepareStackTrace = ()=>{}
[Function (anonymous)] Function <Function <[Object: null prototype] {}>>
> Error.prepareStackTrace
undefined

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