Skip to content

Conversation

@barjin
Copy link
Member

@barjin barjin commented Nov 18, 2025

Worker-based environments (e.g. jest tests) do not have access to globalThis.require() (while calling require() instead works). Deeper investigation shows that tsup doesn't transpile this in a dangerous way, so we can use this here.

Unblocks apify/apify-client-js#782 (tested)
Unblocks failing tests in #570

@barjin barjin self-assigned this Nov 18, 2025
@barjin barjin added the adhoc Ad-hoc unplanned task added during the sprint. label Nov 18, 2025
@github-actions github-actions bot added this to the 128th sprint - Tooling team milestone Nov 18, 2025
@github-actions github-actions bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Nov 18, 2025
Copilot finished reviewing on behalf of barjin November 18, 2025 14:11
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 compatibility issues with createHmacSignatureAsync in worker-based environments (e.g., Jest tests) by changing from globalThis.require() to direct require() calls. The change addresses environments where globalThis.require() is unavailable while require() still works.

  • Replaces conditional globalThis.require() check with try-catch wrapped require() call
  • Adds fallback to dynamic import() when require() fails
  • Wraps both import methods in error handling for better robustness

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

@barjin barjin merged commit 3689d59 into master Nov 18, 2025
15 checks passed
@barjin barjin deleted the fix/require-subtle-crypto-in-node branch November 18, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants