error: panic: runtime error: slice bounds out of range
Describe the bug
Our core library is quite large and uses a lot of dynamic imports, but up until recently has worked well in Stackblitz, even if the build took a little bit.
Recently, during the build step, we get error similar to this in the terminal:
✘ [ERROR] panic: runtime error: slice bounds out of range [:-4294967295] (while printing "node_modules/@arcgis/core/widgets/Daylight/DaylightViewModel.js")
linker.go:5548 +0x84
Error: Build failed with 42 errors:
error: panic: runtime error: slice bounds out of range [:-4294967295] (while printing "node_modules/@arcgis/core/geometry/support/Ellipsoid.js")
error: panic: runtime error: slice bounds out of range [:-4294967295] (while printing "node_modules/@arcgis/core/support/requestUtils.js")
error: panic: runtime error: slice bounds out of range [:-4294967295] (while printing "node_modules/@esri/calcite-components/dist/esm/polyfills/core-js.js")
error: panic: runtime error: slice bounds out of range [:-4294967295] (while printing "node_modules/@arcgis/core/views/3d/state/utils/navigationUtils.js")
error: panic: runtime error: slice bounds out of range [:-4294967295] (while printing "node_modules/@arcgis/core/views/3d/state/NearFarHeuristic.js")
...
at failureErrorWithLog (/home/projects/github-9i57jp/node_modules/esbuild/lib/main.js:1641:15)
at eval (/home/projects/github-9i57jp/node_modules/esbuild/lib/main.js:1049:25)
at eval (/home/projects/github-9i57jp/node_modules/esbuild/lib/main.js:1517:9) {
errors: [Getter/Setter],
warnings: [Getter/Setter]
It's not always the same modules, it can vary per run.
These demo apps do work locally though.
Link to the blitz that caused the error
https://stackblitz.com/edit/github-9i57jp-83iubh?file=main.js
Steps to reproduce
Happens on build
Expected behavior
Normally a dev build on Stackblitz could take up to a minute. Here is a sample from our previous release that worked (takes a minute or so to load): https://stackblitz.com/edit/vitejs-vite-hg4aeh?file=main.js
Parity with Local
- [X] I have run the project in my local machine and I could not reproduce the issue.
Screenshots
No response
Platform
- OS: [Mac OS]
- Browser: [Chrome, Firefox]
- Version: [121.0.6167.85 , 122.0]
Additional context
I thought it might be Vite related since the error mentions esbuild, so tried vite 5.1 beta, same issue. I had some luck with vite 5.0.0-beta.13, but it wasn't consistent, sometimes it worked, sometime I would get the out of bounds error.
Hey @odoe ! :wave: Thanks for the report!
This error seems to be generated by esbuild and I could not find an older version of webcontainer nor esbuild where this error wouldn't eventually appear. I did observed the same as you, which is that it sometimes worked.
I think we need to investigate more, it might still be an issue on our end.
In addition to those errors, I'm also intermittently seeing Failed to resolve import errors:
[plugin:vite:import-analysis] Failed to resolve import "M6_Of_a_hQQc_sgLC00001254" from "node_modules/.vite/deps/chunk-F52XKCWM.js?v=d0fdc3c6". Does the file exist?
/home/projects/github-9i57jp-yh8kfx/node_modules/.vite/deps/chunk-F52XKCWM.js:3:9
1 | import {
2 | i
3 | } from "M6_Of_a_hQQc_sgLC00001254";
| ^
4 | import {
5 | o as o2
at formatError (/home/projects/github-9i57jp-yh8kfx/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:63814:46)
at TransformContext.error (/home/projects/github-9i57jp-yh8kfx/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:63808:19)
at normalizeUrl (/home/projects/github-9i57jp-yh8kfx/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:62083:33)
at async eval (/home/projects/github-9i57jp-yh8kfx/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:62237:47)
at async TransformContext.transform (/home/projects/github-9i57jp-yh8kfx/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:62158:13)
at async Object.transform (/home/projects/github-9i57jp-yh8kfx/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:64109:30)
at async loadAndTransform (/home/projects/github-9i57jp-yh8kfx/node_modules/vite/dist/node/chunks/dep-9