-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Addon-Vitest: Isolate error reasons during postinstall #33295
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
Conversation
2e8b747 to
ef46010
Compare
ef46010 to
b6eb30d
Compare
|
View your CI Pipeline Execution ↗ for commit 578b5e5
☁️ Nx Cloud last updated this comment at |
📝 WalkthroughWalkthroughRefactors Vitest postinstall to collect and emit structured StorybookError instances (with subErrors) instead of strings, adds new Vitest-specific error classes, updates telemetry to accept/emit parent and sub-error events, and changes a dev-start condition to rely on dependencyInstallationResult.status. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
✨ Finishing touches
Comment |
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
code/core/src/core-server/withTelemetry.ts (1)
138-147: Consider adding depth protection for deeply nested sub-errors.While the current implementation correctly handles sub-errors recursively, there's no protection against deeply nested or potentially circular sub-error structures. Consider adding a maximum depth parameter to prevent stack overflow in edge cases.
export async function sendTelemetryError( _error: unknown, eventType: EventType, options: TelemetryOptions, blocking = true, - parent?: StorybookError + parent?: StorybookError, + depth = 0 ) { // ... existing code ... // If this is a StorybookError with sub-errors, send telemetry for each sub-error separately - if (error instanceof StorybookError && error.subErrors.length > 0) { + if (error instanceof StorybookError && error.subErrors.length > 0 && depth < 3) { for (const subError of error.subErrors) { if (subError instanceof StorybookError) { - await sendTelemetryError(subError, eventType, options, blocking, error); + await sendTelemetryError(subError, eventType, options, blocking, error, depth + 1); } } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
code/addons/vitest/src/postinstall.ts(8 hunks)code/core/src/core-server/withTelemetry.ts(2 hunks)code/core/src/server-errors.ts(1 hunks)code/core/src/storybook-error.ts(1 hunks)code/lib/create-storybook/src/initiate.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{js,jsx,json,html,ts,tsx,mjs}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use ESLint and Prettier configurations that are enforced in the codebase
Files:
code/core/src/core-server/withTelemetry.tscode/core/src/server-errors.tscode/addons/vitest/src/postinstall.tscode/lib/create-storybook/src/initiate.tscode/core/src/storybook-error.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Enable TypeScript strict mode
Files:
code/core/src/core-server/withTelemetry.tscode/core/src/server-errors.tscode/addons/vitest/src/postinstall.tscode/lib/create-storybook/src/initiate.tscode/core/src/storybook-error.ts
code/**/*.{ts,tsx,js,jsx,mjs}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
code/**/*.{ts,tsx,js,jsx,mjs}: Use server-side logger from 'storybook/internal/node-logger' for Node.js code
Use client-side logger from 'storybook/internal/client-logger' for browser code
Do not use console.log, console.warn, or console.error directly unless in isolated files where importing loggers would significantly increase bundle size
Files:
code/core/src/core-server/withTelemetry.tscode/core/src/server-errors.tscode/addons/vitest/src/postinstall.tscode/lib/create-storybook/src/initiate.tscode/core/src/storybook-error.ts
code/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Export functions that need to be tested from their modules
Files:
code/core/src/core-server/withTelemetry.tscode/core/src/server-errors.tscode/addons/vitest/src/postinstall.tscode/lib/create-storybook/src/initiate.tscode/core/src/storybook-error.ts
code/**/*.{js,jsx,json,html,ts,tsx,mjs}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
code/**/*.{js,jsx,json,html,ts,tsx,mjs}: Run Prettier with --write flag to format code before committing
Run ESLint with yarn lint:js:cmd to check for linting issues and fix errors before committing
Files:
code/core/src/core-server/withTelemetry.tscode/core/src/server-errors.tscode/addons/vitest/src/postinstall.tscode/lib/create-storybook/src/initiate.tscode/core/src/storybook-error.ts
🧠 Learnings (10)
📓 Common learnings
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Document complex mock behaviors in Vitest tests
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid mocking only a subset of required dependencies in Vitest tests
📚 Learning: 2025-11-24T17:49:59.279Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid mocking only a subset of required dependencies in Vitest tests
Applied to files:
code/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-24T17:49:31.838Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-24T17:49:31.838Z
Learning: Applies to code/vitest.workspace.ts : Vitest configuration is centralized in `code/vitest.workspace.ts` for workspace setup
Applied to files:
code/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-24T17:49:59.279Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid inline mock implementations within test cases in Vitest tests
Applied to files:
code/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-28T14:50:24.889Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-28T14:50:24.889Z
Learning: Applies to code/**/*.{ts,tsx,js,jsx,mjs} : Use server-side logger from 'storybook/internal/node-logger' for Node.js code
Applied to files:
code/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-28T14:50:24.889Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-28T14:50:24.889Z
Learning: Follow existing patterns and conventions in the Storybook codebase
Applied to files:
code/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-05T09:38:47.712Z
Learnt from: Sidnioulz
Repo: storybookjs/storybook PR: 32458
File: code/core/src/components/components/Select/Select.tsx:200-204
Timestamp: 2025-11-05T09:38:47.712Z
Learning: Repo: storybookjs/storybook — Guidance: Until Storybook 11 is released, do not suggest using React.useId anywhere (e.g., in code/core/src/components/components/Select/Select.tsx) to maintain compatibility with React 17 runtimes. Prefer advising: accept a caller-provided props.id and, if needed, generate a client-only fallback id to minimize SSR hydration issues — but avoid useId. Resume prompting for useId after Storybook 11.
Applied to files:
code/addons/vitest/src/postinstall.tscode/lib/create-storybook/src/initiate.ts
📚 Learning: 2025-09-17T07:31:04.432Z
Learnt from: ndelangen
Repo: storybookjs/storybook PR: 32484
File: code/core/package.json:326-326
Timestamp: 2025-09-17T07:31:04.432Z
Learning: In Storybook's core package, dependencies like `open` are bundled into the final distribution during the build process, so they should remain in devDependencies rather than being moved to dependencies. End users don't need these packages as separate runtime dependencies since they're included in the bundled code.
Applied to files:
code/lib/create-storybook/src/initiate.ts
📚 Learning: 2025-09-29T13:20:23.346Z
Learnt from: mrginglymus
Repo: storybookjs/storybook PR: 32556
File: code/core/package.json:309-313
Timestamp: 2025-09-29T13:20:23.346Z
Learning: The `fast-printf` dependency in Storybook's core package is bundled into the final distribution during the build process, so it should remain in devDependencies rather than being moved to dependencies, following the same pattern as other bundled dependencies like `open`.
Applied to files:
code/lib/create-storybook/src/initiate.ts
📚 Learning: 2025-09-24T09:39:39.233Z
Learnt from: ndelangen
Repo: storybookjs/storybook PR: 32507
File: code/core/src/manager/globals/globals-module-info.ts:25-33
Timestamp: 2025-09-24T09:39:39.233Z
Learning: In Storybook, storybook/actions/decorator is a preview-only entrypoint and should not be included in manager globals configuration. The duplicatedKeys array in code/core/src/manager/globals/globals-module-info.ts is specifically for manager-side externalization, not preview entrypoints.
Applied to files:
code/lib/create-storybook/src/initiate.ts
🧬 Code graph analysis (1)
code/addons/vitest/src/postinstall.ts (1)
code/core/src/server-errors.ts (4)
AddonVitestPostinstallExistingSetupFileError(483-497)AddonVitestPostinstallWorkspaceUpdateError(499-513)AddonVitestPostinstallConfigUpdateError(515-529)AddonVitestPostinstallFailedAddonA11yError(471-481)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: normal
- GitHub Check: nx
- GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (14)
code/lib/create-storybook/src/initiate.ts (1)
116-125: LGTM! Clear success condition.The refactor from checking
ErrorCollector.getErrors().length === 0todependencyInstallationResult.status === 'success'is a good improvement. It makes the success condition explicit and self-documenting, directly tied to the installation result rather than relying on a global error collector state.code/core/src/storybook-error.ts (2)
74-93: LGTM! Well-documented sub-errors property.The
subErrorsproperty is properly typed asStorybookError[]with a sensible default of an empty array. The JSDoc documentation clearly explains the purpose and provides a helpful usage example.
101-114: LGTM! Clean constructor extension.The constructor properly accepts an optional
subErrorsparameter and initializes the property with nullish coalescing (props.subErrors ?? []), ensuring consistent behavior.code/core/src/server-errors.ts (3)
471-481: LGTM! New A11y error class.The error class follows the established pattern with a unique code (6) and appropriate
isHandledError: trueflag. Thedataproperty correctly captures the underlying error for debugging purposes.
483-529: LGTM! Well-structured file/workspace/config error classes.The three new error classes (
AddonVitestPostinstallExistingSetupFileError,AddonVitestPostinstallWorkspaceUpdateError,AddonVitestPostinstallConfigUpdateError) are consistently structured with:
- Unique error codes (7, 8, 9)
- Appropriate
isHandledError: trueflags- Documentation links pointing to manual setup instructions
- Clear, actionable error messages
531-542: LGTM! Proper integration of subErrors.The
AddonVitestPostinstallErrornow acceptsStorybookError[]instead ofstring[]and properly passes them via thesubErrorsconstructor parameter. This enables the telemetry system to handle each sub-error individually.code/core/src/core-server/withTelemetry.ts (2)
89-95: LGTM! Clean signature extension.The optional
parent?: StorybookErrorparameter is a clean addition that enables hierarchical error tracking without breaking existing callers.
129-131: LGTM! Parent context propagation.Using spread with conditional inclusion (
...(parent ? { parent: parent.fullErrorCode } : {})) is an idiomatic way to optionally include the parent error code in telemetry data.code/addons/vitest/src/postinstall.ts (6)
40-40: LGTM! Properly typed error collection.The
errorsarray is now correctly typed asStorybookError[], enabling type-safe error aggregation throughout the postinstall flow.
162-171: LGTM! Structured error for existing setup file.The error handling correctly uses the new
AddonVitestPostinstallExistingSetupFileErrorwith the file path, providing better telemetry context than a plain string.
262-265: LGTM! Structured error for workspace update failure.Properly uses
AddonVitestPostinstallWorkspaceUpdateErrorwith the workspace file path for granular error tracking.
309-309: LGTM! Structured error for config update failure.Correctly uses
AddonVitestPostinstallConfigUpdateErrorwith the config file path.
364-371: LGTM! Structured error for A11y addon failure.The error handling captures the underlying exception in
AddonVitestPostinstallFailedAddonA11yError, enabling better debugging through thedata.errorproperty.
29-29: Relative import is necessary — StorybookError is not exported viastorybook/internal/*paths.The
StorybookErrortype cannot be imported fromstorybook/internal/server-errorsbecause it is not re-exported from that path. The baseStorybookErrorclass is internal and only exported fromcode/core/src/storybook-error.ts. The relative import (../../../core/src/storybook-error) is the only valid approach, consistent with howStorybookErroris imported throughout the codebase in other files likeserver-errors.ts,preview-errors.ts, andmanager-errors.ts.
| await addonVitestService.installPlaywright({ | ||
| yes: options.yes, | ||
| }); |
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.
🧩 Analysis chain
🏁 Script executed:
find . -name "AddonVitestService.ts" -o -name "*AddonVitest*" | head -20Repository: storybookjs/storybook
Length of output: 205
🏁 Script executed:
cd code && find . -path "*vitest*" -name "*.ts" -type f | head -20Repository: storybookjs/storybook
Length of output: 814
🏁 Script executed:
cat -n code/core/src/cli/AddonVitestService.ts | head -100Repository: storybookjs/storybook
Length of output: 4307
🏁 Script executed:
wc -l code/core/src/cli/AddonVitestService.tsRepository: storybookjs/storybook
Length of output: 108
🏁 Script executed:
rg -n 'installPlaywright' code/core/src/cli/AddonVitestService.ts -A 30Repository: storybookjs/storybook
Length of output: 1509
🏁 Script executed:
cat -n code/addons/vitest/src/postinstall.ts | head -160Repository: storybookjs/storybook
Length of output: 7263
🏁 Script executed:
rg -n 'installPlaywright' code/core/src/cli/AddonVitestService.ts -A 50 | head -80Repository: storybookjs/storybook
Length of output: 2291
🏁 Script executed:
rg -n 'installPlaywright' code/core/src/cli/AddonVitestService.ts -A 70 | tail -40Repository: storybookjs/storybook
Length of output: 1379
🏁 Script executed:
sed -n '166,190p' code/core/src/cli/AddonVitestService.tsRepository: storybookjs/storybook
Length of output: 710
🏁 Script executed:
sed -n '39,160p' code/addons/vitest/src/postinstall.ts | cat -nRepository: storybookjs/storybook
Length of output: 5533
Handle Playwright installation failures by checking the return value.
The call to addonVitestService.installPlaywright() ignores the returned { errors, result } object. If installation fails (result='failed'), execution continues silently without notifying the user. Capture the return value and either throw an error or log a warning when result === 'failed' to maintain consistency with the error handling pattern used elsewhere in this function (e.g., lines 56-61 for compatibility checks).
🤖 Prompt for AI Agents
In code/addons/vitest/src/postinstall.ts around lines 146 to 148, the call to
addonVitestService.installPlaywright(...) currently ignores the returned {
errors, result } object; capture the return value, check if result === 'failed',
and handle it like the compatibility checks earlier (lines ~56-61) by either
throwing an Error (including the errors payload or a descriptive message) or
logging a warning and exiting—ensure you pass through options.yes as before and
include clear context in the error/warning so installation failures do not
continue silently.
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 39 | 39 | 0 |
| Self size | 20.52 MB | 20.53 MB | 🚨 +12 KB 🚨 |
| Dependency size | 16.41 MB | 16.41 MB | 0 B |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 173 | 173 | 0 |
| Self size | 774 KB | 774 KB | 0 B |
| Dependency size | 67.60 MB | 67.61 MB | 🚨 +12 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 166 | 166 | 0 |
| Self size | 30 KB | 30 KB | 0 B |
| Dependency size | 66.17 MB | 66.18 MB | 🚨 +12 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
create-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 40 | 40 | 0 |
| Self size | 1000 KB | 1000 KB | 🎉 -73 B 🎉 |
| Dependency size | 36.93 MB | 36.94 MB | 🚨 +12 KB 🚨 |
| Bundle Size Analyzer | node | node |
…pe of StorybookError
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.
Actionable comments posted: 0
♻️ Duplicate comments (1)
code/addons/vitest/src/postinstall.ts (1)
146-148: Handle Playwright installation failures by checking the return value.The call to
addonVitestService.installPlaywright()ignores the returned value. If installation fails, execution continues silently without notifying the user. This is inconsistent with the error handling pattern used elsewhere (e.g., lines 69-99 for compatibility checks).Capture the return value and handle failures appropriately:
- await addonVitestService.installPlaywright({ + const { errors: playwrightErrors, result: playwrightResult } = await addonVitestService.installPlaywright({ yes: options.yes, }); + if (playwrightResult === 'failed') { + logger.error('Playwright installation failed'); + if (playwrightErrors && playwrightErrors.length > 0) { + playwrightErrors.forEach(err => logger.error(err)); + } + // Consider whether to throw or push to errors array based on desired behavior + }
🧹 Nitpick comments (1)
code/core/src/server-errors.ts (1)
473-483: Include error details in the message for better debuggability.The captured
erroris not included in the message string, which could make troubleshooting difficult. Consider following the pattern used inGoogleFontsLoadingError(line 330) by conditionally appending the error message.Apply this diff to include error details:
export class AddonVitestPostinstallFailedAddonA11yError extends StorybookError { constructor(public data: { error: unknown | Error }) { super({ name: 'AddonVitestPostinstallFailedAddonA11yError', - message: "The @storybook/addon-a11y couldn't be set up for the Vitest addon", + message: dedent` + The @storybook/addon-a11y couldn't be set up for the Vitest addon. + + ${data.error instanceof Error ? data.error.message : ''}`, category: Category.CLI_INIT, isHandledError: true, code: 6, }); } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
code/addons/vitest/src/postinstall.ts(7 hunks)code/core/src/server-errors.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{js,jsx,json,html,ts,tsx,mjs}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use ESLint and Prettier configurations that are enforced in the codebase
Files:
code/core/src/server-errors.tscode/addons/vitest/src/postinstall.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Enable TypeScript strict mode
Files:
code/core/src/server-errors.tscode/addons/vitest/src/postinstall.ts
code/**/*.{ts,tsx,js,jsx,mjs}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
code/**/*.{ts,tsx,js,jsx,mjs}: Use server-side logger from 'storybook/internal/node-logger' for Node.js code
Use client-side logger from 'storybook/internal/client-logger' for browser code
Do not use console.log, console.warn, or console.error directly unless in isolated files where importing loggers would significantly increase bundle size
Files:
code/core/src/server-errors.tscode/addons/vitest/src/postinstall.ts
code/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Export functions that need to be tested from their modules
Files:
code/core/src/server-errors.tscode/addons/vitest/src/postinstall.ts
code/**/*.{js,jsx,json,html,ts,tsx,mjs}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
code/**/*.{js,jsx,json,html,ts,tsx,mjs}: Run Prettier with --write flag to format code before committing
Run ESLint with yarn lint:js:cmd to check for linting issues and fix errors before committing
Files:
code/core/src/server-errors.tscode/addons/vitest/src/postinstall.ts
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid mocking only a subset of required dependencies in Vitest tests
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Document complex mock behaviors in Vitest tests
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid inline mock implementations within test cases in Vitest tests
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Group related mocks together in Vitest tests
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Implement mock behaviors in `beforeEach` blocks in Vitest tests
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Mock all required properties and methods that the test subject uses in Vitest tests
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid mock implementations outside of `beforeEach` blocks in Vitest tests
📚 Learning: 2025-11-28T14:50:24.889Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-28T14:50:24.889Z
Learning: Applies to code/**/*.{ts,tsx,js,jsx,mjs} : Use server-side logger from 'storybook/internal/node-logger' for Node.js code
Applied to files:
code/core/src/server-errors.tscode/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-28T14:50:24.889Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-28T14:50:24.889Z
Learning: Applies to code/**/*.{ts,tsx,js,jsx,mjs} : Use client-side logger from 'storybook/internal/client-logger' for browser code
Applied to files:
code/core/src/server-errors.tscode/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-28T14:50:24.889Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-28T14:50:24.889Z
Learning: Follow existing patterns and conventions in the Storybook codebase
Applied to files:
code/core/src/server-errors.ts
📚 Learning: 2025-11-05T09:38:47.712Z
Learnt from: Sidnioulz
Repo: storybookjs/storybook PR: 32458
File: code/core/src/components/components/Select/Select.tsx:200-204
Timestamp: 2025-11-05T09:38:47.712Z
Learning: Repo: storybookjs/storybook — Guidance: Until Storybook 11 is released, do not suggest using React.useId anywhere (e.g., in code/core/src/components/components/Select/Select.tsx) to maintain compatibility with React 17 runtimes. Prefer advising: accept a caller-provided props.id and, if needed, generate a client-only fallback id to minimize SSR hydration issues — but avoid useId. Resume prompting for useId after Storybook 11.
Applied to files:
code/core/src/server-errors.tscode/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-24T17:49:59.279Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid mocking only a subset of required dependencies in Vitest tests
Applied to files:
code/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-24T17:49:31.838Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-24T17:49:31.838Z
Learning: Applies to code/vitest.workspace.ts : Vitest configuration is centralized in `code/vitest.workspace.ts` for workspace setup
Applied to files:
code/addons/vitest/src/postinstall.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: normal
- GitHub Check: Core Unit Tests, windows-latest
- GitHub Check: nx
🔇 Additional comments (11)
code/core/src/server-errors.ts (5)
8-8: LGTM!The re-export enables external consumers to access
StorybookErrorthrough the server-errors module, supporting the new structured error handling.
485-499: LGTM!The error class properly captures the file path context and provides clear guidance with documentation links.
501-515: LGTM!The error class properly captures the file path context and provides clear guidance with documentation links.
517-531: LGTM!The error class properly captures the file path context and provides clear guidance with documentation links.
533-544: LGTM!The change from string-based to
StorybookError[]errors enables structured error propagation throughsubErrors, which aligns with the PR's telemetry improvements.code/addons/vitest/src/postinstall.ts (6)
14-22: LGTM!The imports properly support the migration from string-based to structured error handling with typed error classes.
40-40: LGTM!The type change correctly reflects the migration from string-based to structured error instances.
171-171: LGTM!The error instance is properly created with the required
filePathparameter, replacing the previous string-based approach.
262-264: LGTM!The error instance is properly created with the required
filePathparameter, replacing the previous string-based approach.
309-309: LGTM!The error instance is properly created with the required
filePathparameter, replacing the previous string-based approach.
370-370: LGTM!The error instance is properly created with the required
errorparameter, replacing the previous string-based approach.
…iled-errors Addon-Vitest: Isolate error reasons during postinstall (cherry picked from commit 46708d8)
Closes #
What I did
When AddonVitestPostinstallError is thrown with sub-errors, telemetry sends separate events for the parent and each sub-error, improving error tracking and debugging.
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake sure this PR contains one of the labels below:
Available labels
bug: Internal changes that fixes incorrect behavior.maintenance: User-facing maintenance tasks.dependencies: Upgrading (sometimes downgrading) dependencies.build: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup: Minor cleanup style change. Will not show up in release changelog.documentation: Documentation only changes. Will not show up in release changelog.feature request: Introducing a new feature.BREAKING CHANGE: Changes that break compatibility in some way with current major version.other: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/coreteam here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>Summary by CodeRabbit
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.