Skip to content

Conversation

@kypp
Copy link

@kypp kypp commented Dec 25, 2025

Fix: keep run dependency helpers when FETCH uses IndexedDB

Fetch.init() calls addRunDependency/removeRunDependency when FETCH_SUPPORT_INDEXEDDB is enabled. In -s MODULARIZE=1 builds those helpers can be DCE'd, causing ReferenceError: addRunDependency is not defined at runtime.

This change declares $addRunDependency and $removeRunDependency as deps of $Fetch (guarded by FETCH_SUPPORT_INDEXEDDB), so the helpers are retained without requiring extra user flags.

Fixes #26008

Repro:

emcc main.c -s FETCH=1 -s MODULARIZE=1 -o out.mjs

Open the output in a browser:

  • Before: ReferenceError: addRunDependency is not defined
  • After: no error

Copilot AI review requested due to automatic review settings December 25, 2025 14:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a dead code elimination (DCE) issue in MODULARIZE builds where the Fetch API uses IndexedDB. The Fetch.init() function calls addRunDependency/removeRunDependency when IndexedDB support is enabled, but these helper functions were being removed by DCE, causing a ReferenceError at runtime.

  • Adds $addRunDependency and $removeRunDependency as dependencies of $Fetch when FETCH_SUPPORT_INDEXEDDB is enabled
  • Prevents DCE from removing these runtime helper functions in MODULARIZE builds

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Fetch.js calls addRunDependency/removeRunDependency but helpers are stripped in MODULARIZE builds

1 participant