dougwilson/nodejs-depd

`callSite.getFileName` is not a function

loynoir opened this issue · 10 comments

$ 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

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!

"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)

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.

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)

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.

I'm not sure what that link means.

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

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.

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