Fix crash on certain versions of Tizen and Samsung Internet #11148
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue description
A friend was having issues with Jellyfin on his Samsung Smart TV. Running the program, the following stack trace displayed:
It reads out:
TypeError: Failed to construct 'Headers': No matching constructor signature.
Tracking this down, it is due to some
react-router
code. Turns out, this is due to a bug in Samsung's JavaScript implementation.new Headers(undefined)
should be a valid constructor, but running this on Samsung, this errors. I suggested updating the browser, but this was not possible, as the version was locked.Fix
Thus, like in other projects I've seen, I've implemented the fix of running the constructor with an empty object (
new Headers({})
) instead ofundefined
ornull
().new Headers(undefined)
This is inspired from the following work:
new Headers(undefined)
throw? whatwg/fetch#185These changes increase compatibility, making it possible to run
react-router
on older browser implementations, and introduce no breaking changes.After building using this fork of React Router, the program was no longer crashing on my friend's Tizen system.