libsql / libsql/isomorphic-ts

TypeError: Invalid URL caused by mismatch in fetch()

Open
#10 1 comment 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2
Forks
5
PR merge metrics
No merged PRs in 30d

Description

Describe the issue

Using Remix 2.9.2 with any version of libsql/client >= 0.6.0 results in the following error:

node:internal/url:814
    const href = bindingUrl.parse(input, base, raiseException);
                            ^

TypeError: Invalid URL
    at new URL (node:internal/url:814:29)
    at new Request (/home/ali/Desktop/remix-template-starter/node_modules/@remix-run/web-fetch/dist/lib.node.cjs:1437:16)
    at /home/ali/Desktop/remix-template-starter/node_modules/@remix-run/web-fetch/dist/lib.node.cjs:1732:19
    at new Promise (<anonymous>)
    at fetch (/home/ali/Desktop/remix-template-starter/node_modules/@remix-run/web-fetch/dist/lib.node.cjs:1729:9)
    at fetchWithAgentSelection (file:///home/ali/Desktop/remix-template-starter/node_modules/@libsql/isomorphic-fetch/node.js:19:12)
    at #flush (file:///home/ali/Desktop/remix-template-starter/node_modules/@libsql/hrana-client/lib-esm/http/stream.js:245:23)
    at #flushPipeline (file:///home/ali/Desktop/remix-template-starter/node_modules/@libsql/hrana-client/lib-esm/http/stream.js:233:20)
    at #flushQueue (file:///home/ali/Desktop/remix-template-starter/node_modules/@libsql/hrana-client/lib-esm/http/stream.js:223:32)
    at file:///home/ali/Desktop/remix-template-starter/node_modules/@libsql/hrana-client/lib-esm/http/stream.js:181:50 {
  code: 'ERR_INVALID_URL',
  input: '[object Request]'
}

Downgrading to libsql/client 0.5.6 fixes the issue, as discovered by the following issues:
https://github.com/tursodatabase/libsql-client-ts/issues/204
https://github.com/prisma/prisma/issues/23774

However, after investigating, I've noticed that the issue isn't due to using a version of libsql/client >= 0.6.0, as I was able to use 0.6.2 with the condition that I downgrade libsql/isomorphic-fetch to 0.1.12 which is a dependency of @libsql/hrana-client which is a dependency of libsql/client. I've then started looking at the changes between libsql/isomorphic-fetch 0.1.12 and 0.2.0, which is just this 1 commit thankfully: https://github.com/libsql/isomorphic-ts/commit/218800bd2c806e0f7537e427a516c04e4dede538

And what I've noticed is that now, we are passing the entire Request object as the first argument to the fetch function, going back at the error mentioned above, specifically this one here:

at fetch (/home/ali/Desktop/remix-template-starter/node_modules/@remix-run/web-fetch/dist/lib.node.cjs:1729:9)

What is happening here is that the fetch function from @remix-run/web-fetch, tries to treat it as a string URL, leading to the ERR INVALID URL error, because we are trying to pass it the entire Request object:

 input: '[object Request]'

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the libsql/isomorphic-fetch 0.1.12 and 0.2.0 changes, especially commit 218800bd2c806e0f7537e427a516c04e4dede538. Trace the Request passed through fetchWithAgentSelection, @libsql/hrana-client, and Remix's @remix-run/web-fetch; done means the Request is handled without producing ERR_INVALID_URL.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.