-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
TypeError: Cannot read properties of undefined (reading 'imports') #6832
Comments
It seems to cause vitest-dev/vitest#6832
Note that sometimes it still fail even without |
I add some logs to it, it fails at: const output = esbuildOutputFromId(
meta.outputs,
id,
processingCacheDir
;
...
JSON.stringify(output.imports) // here
{
'../../testcases/react-vite-ts/node_modules/.vite/deps_temp_3433dfbb/pixelmatch.js.map': { imports: [], exports: [], inputs: {}, bytes: 13902 },
'../../testcases/react-vite-ts/node_modules/.vite/deps_temp_3433dfbb/pixelmatch.js': {
imports: [ [Object] ],
exports: [ 'default' ],
entryPoint: '../../node_modules/.pnpm/pixelmatch@6.0.0/node_modules/pixelmatch/index.js',
inputs: {
'../../node_modules/.pnpm/pixelmatch@6.0.0/node_modules/pixelmatch/index.js': [Object]
},
bytes: 6014
},
'../../testcases/react-vite-ts/node_modules/.vite/deps_temp_3433dfbb/storybook_internal_channels.js.map': { imports: [], exports: [], inputs: {}, bytes: 93 },
'../../testcases/react-vite-ts/node_modules/.vite/deps_temp_3433dfbb/storybook_internal_channels.js': {
imports: [ [Object], [Object] ],
exports: [
'Channel',
'PostMessageTransport',
'WebsocketTransport',
'createBrowserChannel'
],
entryPoint: '../../node_modules/.pnpm/storybook@8.3.6/node_modules/storybook/core/channels/index.js',
inputs: {
'../../node_modules/.pnpm/storybook@8.3.6/node_modules/storybook/core/channels/index.js': [Object]
},
bytes: 270
},
'../../testcases/react-vite-ts/node_modules/.vite/deps_temp_3433dfbb/@storybook_test.js.map': { imports: [], exports: [], inputs: {}, bytes: 1527003 },
'../../testcases/react-vite-ts/node_modules/.vite/deps_temp_3433dfbb/@storybook_test.js': {
imports: [ [Object], [Object], [Object] ],
exports: [
'buildQueries',
'clearAllMocks',
'configure',
'createEvent',
'expect',
'findAllByAltText',
'findAllByDisplayValue',
'custom',
'inspect',
'lib_default',
'registerConstructor',
'registerStringTag'
],
inputs: {
'browser-external:util': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/helpers.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/array.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/typedarray.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/date.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/function.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/map.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/number.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/bigint.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/regexp.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/set.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/string.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/symbol.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/promise.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/object.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/class.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/arguments.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/error.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/html.js': [Object],
'../../node_modules/.pnpm/loupe@3.1.2/node_modules/loupe/lib/index.js': [Object]
},
bytes: 20074
},
'../../testcases/react-vite-ts/node_modules/.vite/deps_temp_3433dfbb/chunk-2TUXWMP5.js.map': { imports: [], exports: [], inputs: {}, bytes: 93 },
'../../testcases/react-vite-ts/node_modules/.vite/deps_temp_3433dfbb/chunk-2TUXWMP5.js': {
imports: [],
exports: [
'__commonJS',
'__export',
'__publicField',
'__require',
'__toESM'
],
inputs: {},
bytes: 2209
}
} |
I changed the logs to better show what's the problem: Trace: esbuildOutputFromId cannot locate output: react
cwd: /home/runner/work/storybook-addon-vis/storybook-addon-vis
cacheDirOutputPath: /home/runner/work/storybook-addon-vis/storybook-addon-vis/testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16
normalizedOutputPath: testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/react.js
testPaths: ../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/pixelmatch.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/pixelmatch.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/storybook_internal_channels.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/storybook_internal_channels.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/@storybook_test.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/@storybook_test.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/react-18-N3LFYOCR.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/react-18-N3LFYOCR.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/vitest___@vitest_utils___loupe.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/vitest___@vitest_utils___loupe.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/@vitest_browser___@testing-library_user-event.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/@vitest_browser___@testing-library_user-event.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/@vitest_browser___@testing-library_dom.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/@vitest_browser___@testing-library_dom.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/@storybook_react.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/@storybook_react.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-SIYMET6G.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-SIYMET6G.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-KS2XOV6Z.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-KS2XOV6Z.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/@testing-library_react.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/@testing-library_react.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-JCWZPSOH.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-JCWZPSOH.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-R4Q7MLCB.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-R4Q7MLCB.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-M6PHUQY3.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-M6PHUQY3.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chai.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chai.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/dedent.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/dedent.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/expect-type.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/expect-type.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/react.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/react.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/react-dom.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/react-dom.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-XMNNGJFR.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-XMNNGJFR.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/react_jsx-dev-runtime.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/react_jsx-dev-runtime.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/react_jsx-runtime.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/react_jsx-runtime.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-4DCPJHYI.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-4DCPJHYI.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/vitest___expect-type.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/vitest___expect-type.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-ZYKTUFVC.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-ZYKTUFVC.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/vitest___@vitest_snapshot___magic-string.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/vitest___@vitest_snapshot___magic-string.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/vitest___chai.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/vitest___chai.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-AOBQ2QTI.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-AOBQ2QTI.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/vitest___chai___loupe.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/vitest___chai___loupe.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-CO7AV33B.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-CO7AV33B.js
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-2TUXWMP5.js.map
../../testcases/react-vite-ts/node_modules/.vite/deps_temp_96249d16/chunk-2TUXWMP5.js
at esbuildOutputFromId (file:///home/runner/work/storybook-addon-vis/storybook-addon-vis/node_modules/.pnpm/vite@5.4.10_patch_hash=yxgidkvfiyjalv7bn63o44e6y4_@types+node@22.8.1/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:5[113](https://github.com/repobuddy/storybook-addon-vis/actions/runs/11654506689/job/32448111859#step:9:116)6:10)
at file:///home/runner/work/storybook-addon-vis/storybook-addon-vis/node_modules/.pnpm/vite@5.4.10_patch_hash=yxgidkvfiyjalv7bn63o44e6y4_@types+node@22.8.1/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:50821:24
at process.processTicksAndRejections (node:internal/process/task_queues:105:5) So the problems is the |
Here is my patched code to emit the logs: function esbuildOutputFromId(outputs, id, cacheDirOutputPath) {
const cwd = process.cwd();
const flatId = flattenId(id) + ".js";
const normalizedOutputPath = normalizePath$3(
path$n.relative(cwd, path$n.join(cacheDirOutputPath, flatId))
);
const output = outputs[normalizedOutputPath];
if (output) {
return output;
}
const testPaths = []
for (const [key, value] of Object.entries(outputs)) {
const testPath = normalizePath$3(path$n.relative(cwd, key))
testPaths.push(testPath)
if (testPath === normalizedOutputPath) {
return value;
}
}
console.trace(`esbuildOutputFromId cannot locate output: ${id}
cwd: ${cwd}
cacheDirOutputPath: ${cacheDirOutputPath}
normalizedOutputPath: ${normalizedOutputPath}
testPaths: ${testPaths.join('\n')}
`);
} |
This is not Vitest code, this is an error in Vite. But it's possible the error happens because of how workspace projects are loaded. #6811 should fix it |
Note that the failure does not happen all the times. I think the failure rate is about 10% in CI and less than 2% locally. |
IMO the problem is related to shared caching. I couldn't get it to work even I remove To "fix" it, instead of running |
Describe the bug
When running
vitest
on https://github.com/repobuddy/storybook-addon-vis/tree/und-imports,I notice it emits two warnings:
``sh
10:39:13 AM [vite] ✨ new dependencies optimized: @vitest/coverage-v8/browser
10:39:13 AM [vite] ✨ optimized dependencies changed. reloading
[vitest] Vite unexpectedly reloaded a test. This may cause tests to fail, lead to flaky behaviour or duplicated test runs.
For a stable experience, please add mentioned dependencies to your config's
optimizeDeps.include
field manually....
10:39:15 AM [vite] ✨ new dependencies optimized: @storybook/experimental-addon-test/internal/test-utils
10:39:15 AM [vite] ✨ optimized dependencies changed. reloading
[vitest] Vite unexpectedly reloaded a test. This may cause tests to fail, lead to flaky behaviour or duplicated test runs.
For a stable experience, please add mentioned dependencies to your config's
optimizeDeps.include
field manually.Reproduction
https://github.com/repobuddy/storybook-addon-vis/tree/und-imports
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: