Skip to content

Commit

Permalink
fix: add node custom inspect for URL.searchParams (#12763)
Browse files Browse the repository at this point in the history
fixes #11482

Since URL.searchParams is an object too, we needed to make the tracked property loggable, similar to the URL object itself. This prevents the crashing when logging it in the server load.
  • Loading branch information
eltigerchino authored Oct 7, 2024
1 parent 3591411 commit 2292170
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/rude-shirts-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: prevent crash when logging URL search params in a server load function
5 changes: 5 additions & 0 deletions packages/kit/src/utils/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ export function make_trackable(url, callback, search_params_callback) {
tracked[Symbol.for('nodejs.util.inspect.custom')] = (depth, opts, inspect) => {
return inspect(url, opts);
};

// @ts-ignore
tracked.searchParams[Symbol.for('nodejs.util.inspect.custom')] = (depth, opts, inspect) => {
return inspect(url.searchParams, opts);
};
}

if (DEV || !BROWSER) {
Expand Down

0 comments on commit 2292170

Please sign in to comment.