Skip to content

esm import breaks in web worker #2976

Closed

Description

@psytron

Ethers Version

5.6.esm.min.js

Search Terms

es6 esm import web worker

Describe the Problem

importing ethers in web worker throws exceptions about missing window object

expected behavior: use ethers inside web worker to improve CPU efficiency while rendering UI
Screen Shot 2022-05-11 at 11 57 28 PM

Code Snippet

// web_worker.js
import { ethers } from './ethers-5.6.esm.min.js';

Temp work around ?

// ethers-5.6.esm.min.js
var window = self;  

Contract ABI

No response

Errors

No response

Environment

No response

Environment (Other)

No response

Activity

  1. removed
    investigateUnder investigation and may be a bug.
    on May 13, 2022
  2. ricmoo commented on May 13, 2022

    @ricmoo
    Member

    Are you sure you are on the most recent version of ethers? If so, can you use the non-minified version so you can provide a better line number? :)

  3. psytron commented on May 14, 2022

    @psytron
    Author

    lnum

    Using: https://raw.githubusercontent.com/ethers-io/ethers.js/master/packages/ethers/dist/ethers.esm.js
  4. psytron commented on May 20, 2022

    @psytron
    Author
    var window = self;
    

    Adding this on line 4909 seems to fix the issue. It imports successfully and ethers appears to be functioning normally in web workers. Hopefully something else isn't breaking or requiring separate version of ethers for non-web-worker use :)

  5. added
    investigateUnder investigation and may be a bug.
    on-deckThis Enhancement or Bug is currently being worked on.
    bugVerified to be an issue.
    and removed
    investigateUnder investigation and may be a bug.
    on May 20, 2022
  6. ricmoo commented on May 20, 2022

    @ricmoo
    Member

    I've confirmed this issue. Researching how to fix it now, as the dust files are generated by rollup; there is likely some config to make this play nicely with others.

  7. added
    fixed/completeThis Bug is fixed or Enhancement is complete and published.
    and removed
    on-deckThis Enhancement or Bug is currently being worked on.
    on May 21, 2022
  8. ricmoo commented on May 21, 2022

    @ricmoo
    Member

    This should be fixed in 5.6.7. Please try it out and let me know.

    Thanks! :)

  9. psytron commented on May 22, 2022

    @psytron
    Author

    Confirmed imports perfectly now
    ethers.version => 'ethers/5.6.7'
    Excellent !! Thank You! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugVerified to be an issue.fixed/completeThis Bug is fixed or Enhancement is complete and published.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions