Skip to content

Conversation

@rupansh
Copy link
Contributor

@rupansh rupansh commented Jul 3, 2025

Description

When ic-agent is used inside a rust web worker environment, the sleep function panics as the window object is not available. This PR fixes the sleep function so it uses the appropriate self object instead (more here: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers#web_workers_api)

How Has This Been Tested?

Its a bit difficult to test this e2e as I encountered this panic when my worker was rate limited. I can create a minimal web worker which specifically uses sleep written like this if you feel its necessary.

Checklist:

  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.

@rupansh rupansh requested a review from a team as a code owner July 3, 2025 18:45
@rupansh rupansh changed the title Fix ic-agent for web worker environments fix(ic-agent): fix ic-agent for web worker environments Jul 3, 2025
@adamspofford-dfinity adamspofford-dfinity enabled auto-merge (squash) December 1, 2025 11:50
@adamspofford-dfinity adamspofford-dfinity merged commit 6032db3 into dfinity:main Dec 1, 2025
25 checks passed
@rupansh rupansh deleted the rupansh/agent-worker-fix branch December 1, 2025 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants