Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/client-runtime/src/errors/safeLog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ describe("safeErrorLogAttributes", () => {
error.stack = [
"ProjectRemovalError: outer-error-secret-sentinel",
" at removeProject (https://user:password@example.com/project.ts?token=secret#fragment)",
" at loadSettings (http://localhost:5173/src/useSettings.ts?t=1730700000000:162:7)",
"removeAll@https://example.com/app.js?token=secret:12:5",
].join("\n");

const attributes = safeErrorLogAttributes(error);
Expand All @@ -22,7 +24,11 @@ describe("safeErrorLogAttributes", () => {
errorName: "Error",
errorTag: "ProjectRemovalError",
traceId: "trace-safe-123",
stack: " at removeProject (https://example.com/project.ts)",
stack: [
" at removeProject (https://example.com/project.ts)",
" at loadSettings (http://localhost:5173/src/useSettings.ts:162:7)",
"removeAll@https://example.com/app.js:12:5",
].join("\n"),
});
const diagnosticText = Object.values(attributes).map(String).join("\n");
expect(diagnosticText).not.toContain("outer-error-secret-sentinel");
Expand Down
4 changes: 3 additions & 1 deletion packages/client-runtime/src/errors/safeLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ function readSafeLabel(value: unknown): string | undefined {
function sanitizeStackUrl(value: string): string {
try {
const url = new URL(value);
// A frame's trailing :line:column parses as part of the query or fragment when one is present.
const position = /(?::\d+){1,2}$/.exec(url.hash || url.search)?.[0] ?? "";
url.username = "";
url.password = "";
url.search = "";
url.hash = "";
return url.toString();
return url.toString() + position;
} catch {
return value;
}
Expand Down
Loading