You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling loadStoryblokBridge (loadBridge), the promise won't resolve or reject properly in certain cases.
Instead of calling return;, the promise should be resolved or rejected, based on the reason of returning early.
In the first case, if window is undefined, reject() should be called with an error. The second case, where the script tag already exists, the promise should just be resolved by calling resolve().
Check the Stackblitz app. The console logs will never be outputted, after loading the script. The reason for this, in the reproduction, is because the script tag already exists in index.html, which could be a real case.
If any condition in loadBridge forces a return; call, the promise will never resolve.
edodusi
added
bug
[Issue] Something isn't working
and removed
pending-author
[Issue] Awaiting further information or action from the issue author
pending-triage
[Issue] Ticket is pending to be prioritised
labels
Feb 4, 2025
Thanks @addemod for reporting this, we will investigate on a fix
alvarosabu
added
p3-significant
[Priority] Moderate issues, major enhancements
p2-nice-to-have
[Priority] Lower priority, beneficial enhancements that are not urgent.
and removed
bug
[Issue] Something isn't working
p2-nice-to-have
[Priority] Lower priority, beneficial enhancements that are not urgent.
labels
Feb 12, 2025
Describe the issue you're facing
When calling loadStoryblokBridge (loadBridge), the promise won't resolve or reject properly in certain cases.
Instead of calling
return;
, the promise should be resolved or rejected, based on the reason of returning early.In the first case, if window is undefined,
reject()
should be called with an error. The second case, where the script tag already exists, the promise should just be resolved by callingresolve()
.Should reject:
storyblok-js/src/bridge.ts
Line 7 in 940cf3c
Should resolve:
storyblok-js/src/bridge.ts
Line 24 in 940cf3c
Reproduction
https://stackblitz.com/edit/js-gn3awrkt?file=index.js
Steps to reproduce
Check the Stackblitz app. The console logs will never be outputted, after loading the script. The reason for this, in the reproduction, is because the script tag already exists in index.html, which could be a real case.
If any condition in
loadBridge
forces areturn;
call, the promise will never resolve.System Info
Used Package Manager
pnpm
Error logs (Optional)
No response
Validations
The text was updated successfully, but these errors were encountered: