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.

adapter-node is erroring on all requests

See original GitHub issue

Updating adapt-node from "1.0.0-next.09", to "1.0.0-next.11" is now resulting in the error always being raised when running the server.

node build/index.js

Listening on port 3000
node:internal/process/promises:245
          triggerUncaughtException(err, true /* fromPromise */);
          ^

TypeError [ERR_INVALID_URL]: Invalid URL: /
    at new NodeError (node:internal/errors:329:5)
    at onParseError (node:internal/url:537:9)
    at new URL (node:internal/url:613:5)
    at Array.<anonymous> (file:///Users/samccone/Desktop/repos/edit/build/index.js:14294:18)
    at loop (file:///Users/samccone/Desktop/repos/edit/build/index.js:13728:58)
    at next (file:///Users/samccone/Desktop/repos/edit/build/index.js:13729:69)
    at Array.noop_handler (file:///Users/samccone/Desktop/repos/edit/build/index.js:14283:44)
    at loop (file:///Users/samccone/Desktop/repos/edit/build/index.js:13728:58)
    at next (file:///Users/samccone/Desktop/repos/edit/build/index.js:13729:69)
    at Array.<anonymous> (file:///Users/samccone/Desktop/repos/edit/build/index.js:14012:28) {
  input: '/',
  code: 'ERR_INVALID_URL'
}

^ This results in the server crashing and not serving a 404 which is also interesting

I have confirmed that downgrading back to 09 fixes the issue on my end.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
Conduitrycommented, Mar 31, 2021

This snuck through CI because the adapters don’t currently have tests - #639.

I’ll open a PR with a fix for the Node adapter and the simplification for the Vercel adapter.

1reaction
Conduitrycommented, Mar 31, 2021

My proposed fix is

diff --git a/packages/adapter-node/src/server.js b/packages/adapter-node/src/server.js
index f93e6cb..15947db 100644
--- a/packages/adapter-node/src/server.js
+++ b/packages/adapter-node/src/server.js
@@ -31,7 +31,7 @@ const assets_handler = sirv(join(__dirname, '/assets'), {
 
 polka()
 	.use(compression({ threshold: 0 }), assets_handler, prerendered_handler, async (req, res) => {
-		const parsed = new URL(req.url || '');
+		const parsed = new URL(req.url || '', 'http://localhost');
 		const rendered = await app.render({
 			method: req.method,
 			headers: req.headers, // TODO: what about repeated headers, i.e. string[]
diff --git a/packages/adapter-vercel/src/entry.js b/packages/adapter-vercel/src/entry.js
index 38b7cde..5af07aa 100644
--- a/packages/adapter-vercel/src/entry.js
+++ b/packages/adapter-vercel/src/entry.js
@@ -3,8 +3,7 @@ import { URL } from 'url';
 import { get_body } from '@sveltejs/kit/http';
 
 export default async (req, res) => {
-	const host = `${req.headers['x-forwarded-proto']}://${req.headers.host}`;
-	const { pathname, searchParams } = new URL(req.url || '', host);
+	const { pathname, searchParams } = new URL(req.url || '', 'http://localhost');
 
 	const { render } = await import('./server/app.mjs');
 

but I don’t know why tests didn’t catch this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SvelteKit: Using @sveltejs/adapter-node throwing error
I made a configuration changes (instead of @sveltejs/adapter-auto, I used '@sveltejs/adapter-node') in svelte.config.js file. While making the ...
Read more >
Node Red crashes and exits with 1 - General
Sill crashing. I deleted and re installed node red from docker. Added all the pallets, then imported my flows... crashing again. I am...
Read more >
Solved: CLD200 - Manual Deployment keeps erroring out
Solved: I am going through the CLD200 documentation stepwise and building the sample application. It has been working properly, until I get to...
Read more >
Framework, Host, and Services Metric Reference Manual
This metric displays the Globally Unique Identifier of the Host Channel Adapter node. Target Version. Collection Frequency. All Versions. Every 5 Minutes.
Read more >
[Solved]-hubot fails to start with flowdock adapter-node.js
Copyright 2022 www.appsloveworld.com. All rights reserved. Ezoic report this ad ...
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