evanw/esbuild

After upgrading from 0.24.0 to 0.24.1: panic: runtime error: index out of range [222] with length 222

Opened this issue ยท 13 comments

After upgrading from 0.24.0 to 0.24.1 without any other change I get the following go runtime error:

panic: runtime error: index out of range [222] with length 222

goroutine 76290 [running]:
github.com/evanw/esbuild/internal/sourcemap.DecodeVLQ({0xc018a95702, 0xde, 0x2?}, 0xc039be5a80?)
	github.com/evanw/esbuild/internal/sourcemap/sourcemap.go:126 +0x110
github.com/evanw/esbuild/internal/sourcemap.SourceMapPieces.Finalize({{0xc018a95200, 0x502, 0x5f3}, {0xc018a95702, 0xde, 0xf1}, {0xc018a957e0, 0x13, 0x13}}, {0xc013826360, ...})
	github.com/evanw/esbuild/internal/sourcemap/sourcemap.go:320 +0x474
github.com/evanw/esbuild/internal/linker.(*linkerContext).generateChunksInParallel.func1(_, {{0xc010759880, 0x19}, 0xc0243913b0, {{0xc023702700, 0xc, 0xc}}, {0xc0242d0f00, 0x2, 0x2}, ...})
	github.com/evanw/esbuild/internal/linker/linker.go:714 +0xa55
created by github.com/evanw/esbuild/internal/linker.(*linkerContext).generateChunksInParallel in goroutine 10
	github.com/evanw/esbuild/internal/linker/linker.go:658 +0x878
/Users/doberkofler/MyDev/ljs_app/trunk/periscope/node_modules/esbuild/lib/main.js:993
                  reject(new Error(error2));

Unfortunately I currently see now way to create a reproducible example as it happens (only) when doing a complete build in a very lange codebase. If there is anything else I can do to help please let me know.

I'm having a similar issue with the 0.24.1 version:

runtime error: index out of range [7331] with length 7331
goroutine 80 [running]:
github.com/evanw/esbuild/internal/sourcemap.DecodeVLQ({0xc000604489, 0x1ca3, 0x1?}, 0xc00047c200?)
github.com/evanw/esbuild/internal/sourcemap/sourcemap.go:126 +0x110
github.com/evanw/esbuild/internal/sourcemap.SourceMapPieces.Finalize({{0xc000600000, 0x4489, 0x649f}, {0xc000604489, 0x1ca3, 0x2016}, {0xc00060612c, 0x373, 0x373}}, {0xc0002b6000, ...})
github.com/evanw/esbuild/internal/sourcemap/sourcemap.go:320 +0x474
github.com/evanw/esbuild/internal/linker.(*linkerContext).generateChunksInParallel.func1(_, {{0xc000338680, 0x19}, 0xc0004caa80, {{0xc0004034e9, 0x1, 0x1}}, {0xc000012b70, 0x1, 0x1}, ...})
github.com/evanw/esbuild/internal/linker/linker.go:714 +0xa55
created by github.com/evanw/esbuild/internal/linker.(*linkerContext).generateChunksInParallel in goroutine 1
github.com/evanw/esbuild/internal/linker/linker.go:658 +0x878

same with slidev@0.50.0

Bumped into this in an Astro project dev server (Astro 5.0.9 and 5.1.0). Spend quite a bit time to find the culprit as the project doesn't have esbuild as a direct dependency ๐Ÿ˜…

When I install 0.24.0 as a dev dep, the devserver works fine again.

Same with 0.24.1:

panic: runtime error: index out of range [33918] with length 33918

goroutine 5771 [running]:
github.com/evanw/esbuild/internal/sourcemap.DecodeVLQ({0xc00753cf36, 0x847e, 0x1?}, 0xc006644000?)
        github.com/evanw/esbuild/internal/sourcemap/sourcemap.go:126 +0x110
github.com/evanw/esbuild/internal/sourcemap.SourceMapPieces.Finalize({{0xc007526000, 0x16f36, 0x1f462}, {0xc00753cf36, 0x847e, 0x852c}, {0xc0075453b4, 0xae, 0xae}}, {0xc003f08000, ...})
        github.com/evanw/esbuild/internal/sourcemap/sourcemap.go:320 +0x474
github.com/evanw/esbuild/internal/linker.(*linkerContext).generateChunksInParallel.func1(_, {{0xc0012b4940, 0x19}, 0xc005cc5530, {{0xc0040e66ec, 0x1, 0x1}}, {0xc00403b988, 0x1, 0x1}, ...})
        github.com/evanw/esbuild/internal/linker/linker.go:714 +0xa55
created by github.com/evanw/esbuild/internal/linker.(*linkerContext).generateChunksInParallel in goroutine 19
        github.com/evanw/esbuild/internal/linker/linker.go:658 +0x878

We're experiencing the same issue with 0.24.1, pinning to 0.24.0 resolves this for us temporarily.

evanw commented

Adding the unactionable label as I likely can't do anything here without a way to reproduce the issue.

We are also getting this error. I am not getting this error on 0.24.0

Adding the unactionable label as I likely can't do anything here without a way to reproduce the issue.

@evanw I understand but I'm not sure on how to help. I'm building a pretty big TypeScript code base with about 1m loc.
Does the error message tell anything about where or what to look for?

@evanw Just noticed that it only happens when generating source map (sourcemap: true)

evanw commented

I just published version 0.24.2 with a potential fix based on the line number in the stack trace. You can try updating esbuild again and see if your problem is fixed. A reproduction could still be helpful if it's not fixed. And even if it is fixed, it would be ideal to have test coverage for this so that it doesn't regress again.

Wow this was quick and it seems (at least for my build) to be fixed.

I did some testing with smaller projects or examples using esbuild but the problem only seems to happen with "larger" code bases making it very difficult to extract a test case.

In my case, it is solved with the new version. Thanks!