Conversation
cernymatej
commented
Feb 17, 2026
| const idx = script._triggerPromises.push(Promise.race([ | ||
| trigger.then(v => typeof v === 'undefined' || v ? script.load : undefined), | ||
| script._triggerAbortPromise, | ||
| abortPromise, |
Contributor
Author
There was a problem hiding this comment.
not really sure why this was attached to the script object since - if I didn't miss anything - it was only used in this place π€
can't we just pass in a variable?
|
If anyone comes across this, I had been using the code below which was encountering this bug. useScript(
{
src: 'https://script.com/script.js',
crossorigin: false,
},
{
trigger: useScriptTriggerElement({
trigger: 'visible',
el: container,
}),
},
);I have temporarily fixed it with: useScript(
{
src: 'https://script.com/script.js',
crossorigin: false,
},
{
trigger: (load) => {
const { stop } = useIntersectionObserver(
container,
(entries) => {
if (entries[0]?.isIntersecting) {
load();
stop();
}
},
);
},
},
); |
Collaborator
|
Thanks for working on this, looks good :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
π Linked issue
fix nuxt/scripts#597
β Type of change
π Description
This fixes a problem where a stale Vue scope disposal could abort an unrelated trigger during client-side navigation.
When navigating between pages that both use
useScriptwith the samesrc, the new page mounts before the old page unmounts. The old page'sonScopeDisposecalled abort() onscript._triggerAbortController, which by that point was the new scope's controller. This cancelled the new page's trigger and prevented the script from ever loading.