question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fetchFunc doesn't work with fully qualified URLs

See original GitHub issue

TensorFlow.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:

https://github.com/tensorflow/tfjs/blob/a60f32fbb3d12801c35e464a1f5fd173d575097a/tfjs-core/src/io/http.ts#L42

https://github.com/tensorflow/tfjs/blob/602111aa0858bb46837c2091f4507371525aa3f6/tfjs-core/src/io/http.ts#L252-L254

If tfjs resolves any router it won’t construct a handler with the provided user options:

https://github.com/tensorflow/tfjs/blob/602111aa0858bb46837c2091f4507371525aa3f6/tfjs-converter/src/executor/graph_model.ts#L92-L103

I’m not sure what the reasoning for this is, shouldn’t the options be passed through regardless?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pyu10055commented, May 18, 2020

@JesseFarebro Now I understand the issue, yes, we will add a fix to update the fetchFunc for the default http loader.

0reactions
JesseFarebrocommented, May 18, 2020

Thanks @pyu10055, sorry for the confusion.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found