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

Node error if you try to console.log url param from page server file, crashes the page. #6385

Closed
jhubbardsf opened this issue Aug 29, 2022 · 3 comments · Fixed by #6388
Closed

Comments

@jhubbardsf
Copy link
Contributor

jhubbardsf commented Aug 29, 2022

Describe the bug

If you have a +page.server.ts file and you try console log the event, or more specifically even the destructured url param, node will blow up and the page will fail to load. The exact error is in the logs below.

Reproduction

Create a new sveltekit demo app. App a /tester route with a +page.ts and a +page.server.ts file. Try to console.log the destructured url param or just the event object as a whole.

Logs

TypeError: inspect is not a function
    at URL.tracked.<computed> (file:///Users/josh/Engineering/SvelteKit/console-event-error/node_modules/.pnpm/@sveltejs+kit@1.0.0-next.447_svelte@3.49.0+vite@3.0.9/node_modules/@sveltejs/kit/src/utils/url.js:108:10)
    at formatValue (node:internal/util/inspect:763:19)
    at formatProperty (node:internal/util/inspect:1681:11)
    at formatRaw (node:internal/util/inspect:1006:9)
    at formatValue (node:internal/util/inspect:793:10)
    at inspect (node:internal/util/inspect:340:10)
    at formatWithOptionsInternal (node:internal/util/inspect:2006:40)
    at formatWithOptions (node:internal/util/inspect:1888:10)
    at console.value (node:internal/console/constructor:323:14)
    at console.log (node:internal/console/constructor:359:61)
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

System Info

System:
    OS: macOS 12.4
    CPU: (10) arm64 Apple M1 Pro
    Memory: 81.44 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
  Browsers:
    Brave Browser: 104.1.42.97
    Chrome: 104.0.5112.101
    Firefox: 103.0.2
    Firefox Developer Edition: 98.0
    Safari: 15.5
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.69
    @sveltejs/kit: next => 1.0.0-next.447
    svelte: ^3.46.0 => 3.49.0
    vite: ^3.0.8 => 3.0.9

Severity

annoyance

Additional Information

No response

@jhubbardsf jhubbardsf changed the title Node error if you try to console.log url param from page server file. Node error if you try to console.log url param from page server file, crashes the page. Aug 29, 2022
@Conduitry
Copy link
Member

I can't reproduce this in my own project. The code here

tracked[Symbol.for('nodejs.util.inspect.custom')] = (depth, opts, inspect) => {
return inspect(url, opts);
};
seems to be working fine for me. Please provide a clonable repo that reproduces this.

@jhubbardsf
Copy link
Contributor Author

@Conduitry
Copy link
Member

Conduitry commented Aug 29, 2022

Ah ha, it looks like the Node feature that this requires wasn't added until 16.14.0 - nodejs/node#41019 Irritatingly, the docs https://nodejs.org/dist/latest-v16.x/docs/api/util.html#utilinspectcustom don't mention this.

The easiest option for you is going to be to update Node. On our end, we should perhaps just bump up the minimal required version.

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

Successfully merging a pull request may close this issue.

2 participants