Skip to content

Commit ce18eba

Browse files
authoredMar 7, 2023
fix: handle error without line and column in loc (#12312)
1 parent 523d6f7 commit ce18eba

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed
 

‎packages/vite/src/node/server/pluginContainer.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,11 @@ export async function createPluginContainer(
454454
err.frame = err.frame || generateCodeFrame(err.id!, err.loc)
455455
}
456456

457-
if (err.loc && ctx instanceof TransformContext) {
457+
if (
458+
ctx instanceof TransformContext &&
459+
typeof err.loc?.line === 'number' &&
460+
typeof err.loc?.column === 'number'
461+
) {
458462
const rawSourceMap = ctx._getCombinedSourcemap()
459463
if (rawSourceMap) {
460464
const traced = new TraceMap(rawSourceMap as any)
@@ -483,6 +487,15 @@ export async function createPluginContainer(
483487
}
484488
}
485489
}
490+
491+
if (
492+
typeof err.loc?.column !== 'number' &&
493+
typeof err.loc?.line !== 'number' &&
494+
!err.loc?.file
495+
) {
496+
delete err.loc
497+
}
498+
486499
return err
487500
}
488501

0 commit comments

Comments
 (0)
Please sign in to comment.