Skip to content

Intermittent TIMEOUT in /preload/modulepreload-sri-importmap.html and /preload/modulepreload-sri.html #43354

Closed

Description

@yezhizhen
  ▶ TIMEOUT [expected OK] /preload/modulepreload-sri-importmap.html
  │ 
  │ [2026-03-17T12:17:52Z ERROR script::script_module] Fetching module script failed Subresource integrity validation failed
  │   ▶ TIMEOUT [expected PASS] Script should not be loaded if modulepreload's integrity is invalid
  └   └   → Test timed out

https://github.com/servo/servo/actions/runs/23192983114/job/67394708078

From #42964

Activity

  1. yezhizhen commented on Mar 17, 2026

    @yezhizhen
    MemberAuthor
  2. changed the title [-]Intermittent TIMEOUT in `/preload/modulepreload-sri-importmap.html`[/-] [+]Intermittent TIMEOUT in `/preload/modulepreload-sri-importmap.html` and `/preload/modulepreload-sri.html`[/+] on Mar 18, 2026
  3. jdm commented on Mar 18, 2026

    @jdm
    Member
      ▶ TIMEOUT [expected OK] /preload/modulepreload-sri.html
      │ 
      │ [2026-03-18T00:51:39Z ERROR script::script_module] Fetching module script failed Subresource integrity validation failed
      │   ▶ TIMEOUT [expected PASS] Script should not be loaded if modulepreload's integrity is invalid
      └   └   → Test timed out
    
  4. jdm commented on Mar 18, 2026

    @jdm
    Member

    I reproduced this in a debug build.

  5. jdm commented on Mar 18, 2026

    @jdm
    Member

    The timeout occurs when

    document.deferred_script_loaded(&script, load, can_gc);
    is called but we hit this early return:
    if self.ready_state.get() != DocumentReadyState::Interactive {
    return;
    }

  6. jdm commented on Mar 18, 2026

    @jdm
    Member

    Relevant spec:

    This timeout happens when the document is already incorrectly in the Complete ready state. We shouldn't reach that state while there are still deferred scripts pending.

  7. jdm commented on Mar 18, 2026

    @jdm
    Member

    When this occurs, we see:

    1. the parser marks the document's ready state as Interactive
    2. the parser finishes parsing and mark the PageSource as finished
    3. this triggers a call to process_deferred_scripts
    4. but self.deferred_scripts.take_next_ready_to_be_executed() returns None since the fetch isn't complete
    5. the document sees no outstanding loads (??) and says it's time to move on to the next step

    I don't see any use of LoadBlocker in htmlscriptelement.rs, and there's

    // TODO:
    // Step 31.8. Set el's delaying the load event to true.
    which looks like a smoking gun.

  8. jdm commented on Mar 18, 2026

    @jdm
    Member

    fetch_a_classic_script uses Document::fetch, which uses DocumentLoader::fetch_async_with_callback which adds a blocking load. fetch_a_single_module uses DocumentLoader::fetch_async_with_callback if the module owner is a script element, but modulepreload modules do not use a script element owner.

  9. Gae24 commented on Mar 18, 2026

    @Gae24
    Contributor

    fetch_a_classic_script uses Document::fetch, which uses DocumentLoader::fetch_async_with_callback which adds a blocking load. fetch_a_single_module uses DocumentLoader::fetch_async_with_callback if the module owner is a script element, but modulepreload modules do not use a script element owner.

    I thought DocumentLoader::fetch_async_with_callback shouldn't be used because modulepreloads shouldn't delay the load event.

  10. jdm commented on Mar 18, 2026

    @jdm
    Member

    Yes, I agree. The issue is that the script element loading the module needs to delay the load event, but when it sees there's already matching preload request that doesn't happen.

  11. elomscansio commented on Apr 3, 2026

    @elomscansio
    Contributor

    This is fixed by #43741

    #43741 (comment)

  12. yezhizhen commented on Apr 3, 2026

    @yezhizhen
    MemberAuthor

    Gonna open this as the PR not merged yet.

  13. jdm commented on Apr 3, 2026

    @jdm
    Member

    @elomscansio Can you add a "Fixes #43354" to that PR's description in that case?

  14. added a commit that references this issue on Apr 6, 2026
    a7bc4a6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/scriptRelated to the script threadI-intermittentProblem reproduces intermittently.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions