Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The todo page of SvelteKit Demo project doesn't work completely. #2918

Closed
hare0319 opened this issue Nov 25, 2021 · 4 comments
Closed

The todo page of SvelteKit Demo project doesn't work completely. #2918

hare0319 opened this issue Nov 25, 2021 · 4 comments
Milestone

Comments

@hare0319
Copy link

hare0319 commented Nov 25, 2021

Describe the bug

Following the introduction of svelteKit, init the demo project and start the dev server.
Index and about page work fine, but get errors when loading todo page.

Specifically, when load the todo's page, internal server error 500 with message

    Unexpected token F in JSON at position 0
    SyntaxError: Unexpected token F in JSON at position 0

received, rather than proper Todo page

I've done some experiments to figure out what happens, but with no luck. However,
I located that the problem is issued by

	const res = await fetch(`${base}/${resource}`, {
		method: request.method,
		headers: {
			'content-type': 'application/json'
		},
		body: data && JSON.stringify(data)
	});

of src/route/todos/_api.ts.

Also tried to fetch the page from api.svelte.dev directly with url, and find out that

  • Direct request the data from the URL can receive response correctly.
  • Make a fetch directly from the browser with the same page can receive correct response.
  • Make a fetch to the URL from browser with different page receives an abnormal response ( e.g. open google in the browser, call fetch from devtools console)
  • Make a get request form a test client, like thunder client extension of vscode, get "Connection was forcibly closed by a peer." message.

Not sure what's the problem and what can I do to solve this.

Thanks very much in advance.

Reproduction

Simply run following commands as shown on sveltekit's webpage and navigate to Todo page.

npm init svelte@next
npm install
npm run dev

Logs

Browser console displays

client.ts:22 [vite] connecting...
client.ts:52 [vite] connected.
index.mjs:1983 <Routes> received an unexpected slot "default".
todos.json:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error)
index.mjs:1983 <Error> received an unexpected slot "default".
todos:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Server Console shows

request to https://api.svelte.dev/todos/3f40df25-3547-43a7-b29f-dadd18d70a49 failed, reason: read ECONNRESET
FetchError: request to https://api.svelte.dev/todos/3f40df25-3547-43a7-b29f-dadd18d70a49 failed, reason: read ECONNRESET
    at ClientRequest.<anonymous> (file:///C:/home/anony/Playground/nodejs/SvelteDemo/node_modules/@sveltejs/kit/dist/install-fetch.js:5810:11)
    at ClientRequest.emit (node:events:390:28)
    at ClientRequest.emit (node:domain:475:12)
    at TLSSocket.socketErrorListener (node:_http_client:447:9)
    at TLSSocket.emit (node:events:390:28)
    at TLSSocket.emit (node:domain:475:12)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

System Info

Windows 11

System:
    OS: Windows 10 10.0.22000
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 3.73 GB / 15.56 GB
  Binaries:
    Node: 16.13.0 - ~\.nvm\versions\node\v16.13.0\bin\node.EXE
    npm: 8.1.0 - ~\.nvm\versions\node\v16.13.0\bin\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (96.0.1054.34)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.3
    @sveltejs/kit: next => 1.0.0-next.201
    svelte: ^3.44.0 => 3.44.2

WSL2

  System:
    OS: Linux 5.10 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 6.47 GB / 7.55 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.3
    @sveltejs/kit: next => 1.0.0-next.201
    svelte: ^3.44.0 => 3.44.2

I also tried with my old laptop which have Windows 7 installed, node, npm and svelte related stuffs should be the same as above two setups.

Severity

serious, but I can work around it

Additional Information

Created a thread in Discord talk about the issue.

@m-haecker
Copy link

I had the problem too, but only because of an internal proxy and a resulting "unable to get local issuer certificate" when accessing api.svelte.dev. Without the proxy it works as it should.

@hare0319
Copy link
Author

Well, I wish I could access api.svelte.dev without a proxy. Is there any other way to work this around?

Thanks very much.

@hare0319
Copy link
Author

I had the problem too, but only because of an internal proxy and a resulting "unable to get local issuer certificate" when accessing api.svelte.dev. Without the proxy it works as it should.

Em… interesting, I recently found that I can access api.svelte.dev with a proxy… but still have the issue. Do I miss something?

@Rich-Harris Rich-Harris added this to the whenever milestone Apr 24, 2022
@dummdidumm
Copy link
Member

Closing as outdated, the example app no longer contains a todo list.

@dummdidumm dummdidumm closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants