Skip to content

Commit

Permalink
Remove vendored fetch polyfill, update to whatwg-fetch@3.0 (facebook#…
Browse files Browse the repository at this point in the history
…24418)

Summary:
The original reason for vendoring the fetch polyfill was to remove the default blob response type but this was reverted.

Here's a little history around the fetch polyfill and the blob issue:

- Original commit introducing the vendored polyfill: facebook#19333, the goal was to fix a memory leak because our blob implementation doesn't release resources automatically. Not an ideal fix but since the issue was pretty severe and the infra for a proper fix was not in place.
- This introduced an issue when downloading images using `fetch` which was fixed by facebook#22063 which re-added the default blob content type. However that re-introduced the original fetch memory leak.
- We have better infra now with jsi and I was able to get blob deallocation working, see facebook#24405

Currently the vendored fetch polyfill is useless since it was changed back to the original version. We can just use the npm version again. I also updated to 3.0 which brings better spec compliance and support for cancellation via `AbortController`, https://github.com/github/fetch/releases/tag/v3.0.0.

## Changelog

[General] [Changed] - Remove vendored fetch polyfill, update to whatwg-fetch@3.0
Pull Request resolved: facebook#24418

Differential Revision: D14932683

Pulled By: cpojer

fbshipit-source-id: 915e3d25978e8b9d7507ed807e7fba45aa88385a
  • Loading branch information
janicduplessis authored and M-i-k-e-l committed Mar 10, 2020
1 parent 332ff4a commit 9bfda2f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 536 deletions.
4 changes: 4 additions & 0 deletions Libraries/Core/setUpGlobals.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ if (global.window === undefined) {
global.window = global;
}

if (global.self === undefined) {
global.self = global;
}

// Set up process
global.process = global.process || {};
global.process.env = global.process.env || {};
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Network/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

'use strict';

const whatwg = require('../vendor/core/whatwg-fetch');
const whatwg = require('whatwg-fetch');

if (whatwg && whatwg.fetch) {
module.exports = whatwg;
Expand Down
Loading

0 comments on commit 9bfda2f

Please sign in to comment.