Skip to content

JEST_WORKER_ID leaks into Metro bundle #574

Description

@fordat

Problem

When building a production bundle, jest-worker unconditionally sets JEST_WORKER_ID on every worker process it spawns, even EAS builds when no tests are involved.

react-native-dotenv's Babel plugin runs inside those Metro transform workers and inlines variables from process.env into the bundle — including JEST_WORKER_ID, which is not declared in any .env file but is present in the worker's environment because jest-worker set it.

Impact

The result is a production app bundle with JEST_WORKER_ID as a non-null string. JEST_WORKER_ID now appears in third-party library code, in my case react-native-mmkv, which causes problems with that package (permanently sets it in test mode).

Issues with this have been raised in react-native-mmkv but I believe this problem belongs to react-native-dotenv.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions