-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(sveltekit): Fix file system race condition in source map cleaning #19714
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -213,14 +213,16 @@ export async function makeCustomSentryVitePlugins( | |
| // We need to remove the query string from the source map files that our auto-instrument plugin added | ||
| // to proxy the load functions during building. | ||
| const mapFile = `${file}.map`; | ||
| if (fs.existsSync(mapFile)) { | ||
| try { | ||
| const mapContent = (await fs.promises.readFile(mapFile, 'utf-8')).toString(); | ||
| const cleanedMapContent = mapContent.replace( | ||
| // oxlint-disable-next-line sdk/no-regexp-constructor -- no user input + escaped anyway | ||
| new RegExp(escapeStringForRegex(WRAPPED_MODULE_SUFFIX), 'gm'), | ||
| '', | ||
| ); | ||
| await fs.promises.writeFile(mapFile, cleanedMapContent); | ||
| } catch { | ||
| // Map file doesn't exist, nothing to clean | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix PR missing regression test for the changeLow Severity This is a Triggered by project rule: PR Review Guidelines for Cursor Bot |
||
| } | ||
| } | ||
|
|
||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overly broad catch silently swallows non-ENOENT errors
Medium Severity
The new
catchblock silently swallows all errors, not justENOENT(file not found). IfreadFileorwriteFilefails due to permission errors, disk full, or other I/O issues, the failure is silently ignored. The try/catch block just above (lines 202–211) demonstrates the better pattern already used in this file: it checks whether the error is a knownENOENTand logs unexpected errors whendebugis enabled. The same approach would be appropriate here.Additional Locations (1)
packages/sveltekit/src/vite/sourceMaps.ts#L201-L211