fetchFunc doesn't work with fully qualified URLs
See original GitHub issueTensorFlow.js version
2.0.0-rc.4
Describe the problem or feature request
Currently, if you supply fetchFunc
to a function like loadGraphModel
it will ignore fetchFunc
if the URL is a fully qualified URL. For example,
const options = {
fetchFunc: (...args) => {
console.log(`Custom fetch`)
return fetch(...args)
}
}
let model = await loadGraphModel(`/path/model.json`, options) // Works
model = await loadGraphModel(`https://mydomain.com/path/model.json`, options) // Doesn't work
model = await loadGraphModel(`//mydomain.com/path/model.json`, options) // Works
The issue arises as such:
tfjs first tries to resolve a handler for the URL type. This involves iterating over the known routers. It gets to the HTTP router which will resolve if the following isHTTP
check is true:
If tfjs resolves any router it won’t construct a handler with the provided user options:
I’m not sure what the reasoning for this is, shouldn’t the options be passed through regardless?
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Fetching in javascript with absolute url and relative url
A URL that doesn't start with a scheme or with // is treated as a path (part of a relative URL). From http://example.com/foo/...
Read more >URL - Web APIs - MDN Web Docs - Mozilla
Chrome Edge
URL Full support. Chrome32. more. Toggle history Full support. Edge12. Togg...
URL() constructor Full support. Chrome19. Toggle history Full support. Edge12. footn...
createObjectURL Full...
Read more >Making HTTP Requests in Node.js with node-fetch
In this tutorial, we'll be sending GET and POST requests in Node.js using NPM's node-fetch package. It's different from the client side ...
Read more >Fetch API — Emscripten 3.1.26-git (dev) documentation
Passing a fully qualified absolute URL allows downloading files across ... the Fetch API interacts with the browser's IndexedDB API, which can load...
Read more >node fetch only absolute urls are supported - You.com
The isomorphic-unfetch is running by SSR mode, so Node.js needs to know the absolute url to fetch from it, because the back-end doesn't...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@JesseFarebro Now I understand the issue, yes, we will add a fix to update the fetchFunc for the default http loader.
Thanks @pyu10055, sorry for the confusion.