Skip to content

DocStartInjection: bound execute() with a deadline to avoid permanent hangs - #13

Open
kyouhei-horizumi wants to merge 1 commit into
hackademix:mainfrom
kyouhei-horizumi:fix/docstart-injection-execute-deadline
Open

DocStartInjection: bound execute() with a deadline to avoid permanent hangs#13
kyouhei-horizumi wants to merge 1 commit into
hackademix:mainfrom
kyouhei-horizumi:fix/docstart-injection-execute-deadline

Conversation

@kyouhei-horizumi

Copy link
Copy Markdown

Fixes 596.

Adds a timeout to DocStartInjection as a safeguard against cases where script execution never settles.

Firefox previously had a similar issue (Bug 1900222), in which the Promise returned by scripting.executeScript() could remain pending indefinitely instead of resolving or rejecting. A similar failure mode appears to be occurring here.

The timeout prevents DocStartInjection from remaining blocked indefinitely. Because the pending operation cannot be canceled, a timed-out call is not retried, avoiding the accumulation of unresolved operations.

I have only confirmed this behavior on Firefox so far, so please consider this PR a draft for now.

@laniakea64

Copy link
Copy Markdown
Contributor

Is this a fix for that issue, or does it just paper over the symptom?

nscl is not only for NoScript. Should the timeout be optional for the extension to decide whether it wants it or not?

Will this timeout risk stopping security-related scripts before they get to do their job, thereby creating a security hole? Deadlocking might actually be safer than terminating in that case..

Note that the Firefox bug you linked is about CSS, not Javascript, and does not appear to be adding a time deadline.

@kyouhei-horizumi

kyouhei-horizumi commented Sep 6, 2026

Copy link
Copy Markdown
Author

@laniakea64 Thanks for the feedback.

This was intended as a temporary workaround rather than a root-cause fix.
The investigation is still ongoing, but at this point I suspect there may be an issue on the browser side.

I have confirmed a case where execute() neither resolves nor rejects and remains pending indefinitely. This is a case that the existing 3-minute timeout does not catch.

Firefox Bug 1900222 also mentions in Comment 7 that scripting.executeScript() and related APIs could remain pending indefinitely, so I suspect something similar may be happening here.

Will this timeout risk stopping security-related scripts before they get to do their job, thereby creating a security hole?
Deadlocking might actually be safer than terminating in that case..

This timeout only limits how long we wait for the execute() Promise to settle.


I also hadn't realized that NSCL is used by extensions other than NoScript.
Given that, I'm fine with closing this PR without merging it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Firefox can remain stuck while loading pages under high load

2 participants