π Add error callback to AMD require in component loader#361
Conversation
The AMD require call in possiblyGetConfigFromAmd passed a success callback but no error callback, causing failed module loads to be silently swallowed. Add an explicit error callback that surfaces the failure through the existing errorCallback mechanism. Adversarial review: single-line change, no API surface change, error path uses existing errorCallback pattern β no concerns.
|
No actionable comments were generated in the recent review. π βΉοΈ Recent review infoβοΈ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: π Files selected for processing (1)
π WalkthroughWalkthroughWhen Changes
Estimated code review effortπ― 2 (Simple) | β±οΈ ~10 minutes Poem
π₯ Pre-merge checks | β 4 | β 1β Failed checks (1 warning)
β Passed checks (4 passed)
βοΈ Tip: You can configure your own custom pre-merge checks in the settings. β¨ Finishing Touchesπ Generate docstrings
π§ͺ Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
π€ Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/utils.component/src/loaders.ts`:
- Around line 278-280: Remove the leading semicolon before the AMD loader call
and make the err handling robust so non-Error truthy values don't produce "β
undefined"; specifically, change the call that uses (window.amdRequire ||
window.require)([config.require], callback, function (err) {
errorCallback('Failed to load AMD module: ' + config.require + (err ? ' β ' +
err.message : '')) }) to omit the initial semicolon and build the trailing error
text defensively (e.g., use err?.message ?? String(err) or similar) when
invoking errorCallback so config.require, callback,
window.amdRequire/window.require, and errorCallback are used directly and no " β
undefined" is emitted.
πͺ Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
βΉοΈ Review info
βοΈ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0c386549-cd24-474a-9470-5bd14eb9c578
π Files selected for processing (1)
packages/utils.component/src/loaders.ts
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Problem
The AMD
requirecall inpossiblyGetConfigFromAmd(packages/utils.component/src/loaders.ts) passed only a success callback β no error callback. When AMD module resolution fails, the error is silently swallowed, leaving the component load hanging with no diagnostic.Fix
Add an explicit error callback (third argument) to the AMD
requirecall that surfaces the failure through the existingerrorCallbackmechanism, producing a clear message like:Changes
packages/utils.component/src/loaders.ts: Add error callback to the(window.amdRequire || window.require)call.Verification
utils.componenttests pass.Summary by CodeRabbit