Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove any-promise dependency #3381

Merged
merged 3 commits into from
Feb 25, 2020
Merged

Remove any-promise dependency #3381

merged 3 commits into from
Feb 25, 2020

Conversation

cgewecke
Copy link
Collaborator

@cgewecke cgewecke commented Feb 21, 2020

Description

The any-promise package has an unsafe dereferencing of the window object in its code that throws in the Web Worker environment. This PR removes it and falls back on native promises.

What does any-promise do? (from their README)

NOTE: You probably want native promises now

Let your library support any ES 2015 (ES6) compatible Promise and leave the choice to application authors. The application can optionally register its preferred Promise implementation and it will be exported when requiring any-promise from library code.

If no preference is registered, defaults to the global Promise for newer Node.js versions. The browser version defaults to the window Promise, so polyfill or register as necessary.

Essentially, consumers of Web3 can decide which promise to use and Web3 will respect that, since it (usually) requires Promise from any-promise.

Hard to know if anyone is relying on this...

Resources

Fixes #3377 #2211 #1774

Type of change

  • Bug fix (probably non-breaking?)

Checklist:

  • I have selected the correct base branch.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.
  • I ran npm run dtslint with success and extended the tests and types if necessary.
  • I ran npm run test:unit with success.
  • I have executed npm run test:cov and my test cases do cover all lines and branches of the added code.
  • I ran npm run build-all and tested the resulting file/'s from dist folder in a browser.
  • I have updated the CHANGELOG.md file in the root folder.
  • I have tested my code on the live network.

@cgewecke cgewecke added 1.x 1.0 related issues dependencies Review Needed Maintainer(s) need to review labels Feb 21, 2020
@coveralls
Copy link

coveralls commented Feb 21, 2020

Coverage Status

Coverage decreased (-0.009%) to 86.047% when pulling 798faeb on issue/3377 into e937387 on 1.x.

@nivida
Copy link
Contributor

nivida commented Feb 21, 2020

[EDIT - this coverage drop is due to web3-eth-accounts/src/index.js getting smaller after removing a require statement, increasing the proportion of uncovered lines]

Verified ✅

@nivida
Copy link
Contributor

nivida commented Feb 21, 2020

@cgewecke Oh! Have you done some further tests with the PromiEvent object? It would probably be the perfect moment to add some additional test cases for it :)

... and did you also thought about to fix this upstream instead of removing it? (I think the possibility is here that some depending projects do want to support IE11)

Edit:

add some additional test cases for it

"add some explicit test cases for it" this is probably the better wording.

Copy link
Collaborator

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

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

Would also agree that keeping this dependency causes more problems than helping to address. Also adding a Can-I-use-Web-Workers table here for reference. Generally have to say that I have not very much of a picture of how widely web workers are used atm.

@cgewecke
Copy link
Collaborator Author

@nivida

did you also thought about to fix this upstream instead of removing it?

Yes. There have been no changes to any-promise for ~4 years. The problem with the window object has been raised there before in any-promise 29.

On the surface, the lib seems abandoned / a historical artifact but according to npm it continues see significant increases in usage. Its weekly downloads have almost doubled in the last year (base = 1.5 mil)

Screen Shot 2020-02-24 at 8 59 37 AM

RE: testing. I don't know what test to add here. If you can think of one, will happily add.

@holgerd77 holgerd77 merged commit 2abaf54 into 1.x Feb 25, 2020
@holgerd77 holgerd77 deleted the issue/3377 branch February 25, 2020 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues Review Needed Maintainer(s) need to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

web3 -- Web Worker environment still is not supported in 1.2.4
4 participants