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

Not found: /__data.json when use form actions with use:enhance #7434

Closed
dangelomedinag opened this issue Oct 29, 2022 · 8 comments · Fixed by #7445
Closed

Not found: /__data.json when use form actions with use:enhance #7434

dangelomedinag opened this issue Oct 29, 2022 · 8 comments · Fixed by #7445
Labels
bug Something isn't working p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc.

Comments

@dangelomedinag
Copy link

dangelomedinag commented Oct 29, 2022

Describe the bug

I have this code:

<!-- routes/+page.svelte -->

<script>
	import { enhance } from '$app/forms';
</script>

<form method="POST" use:enhance>
	<input type="text" name="text" id="textid" />
	<button type="submit">submit</button>
</form>
// routes/+page.server.js

export const actions = {
	default: () => {
		return {
			success: true
		};
	}
};

when I submit the form, the following error occurs:

Not found: /__data.json
Error: Not found: /__data.json
    at resolve (file:///C:/Users/dange/Documents/dev/sveltekit/node_modules/@sveltejs/kit/src/runtime/server/index.js:264:13)
    at resolve (file:///C:/Users/dange/Documents/dev/sveltekit/node_modules/@sveltejs/kit/src/runtime/server/index.js:295:5)
    at Object.handle (file:///C:/Users/dange/Documents/dev/sveltekit/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:343:66)
    at respond (file:///C:/Users/dange/Documents/dev/sveltekit/node_modules/@sveltejs/kit/src/runtime/server/index.js:292:40)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///C:/Users/dange/Documents/dev/sveltekit/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:413:22

exactly the same happens if they are named actions, when using use:enhance I get the same error.
I thought it was related to #7410, but I updated to the latest version and the error described still occurs

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-kbaf32?file=src/routes/+page.svelte

other option (local)

npm create svelte@latest 
// zero configuration
add files /+page.svelte and /+page.server.js

Logs

Not found: /__data.json
Error: Not found: /__data.json
    at resolve (file:///C:/Users/dange/Documents/dev/sveltekit/node_modules/@sveltejs/kit/src/runtime/server/index.js:264:13)
    at resolve (file:///C:/Users/dange/Documents/dev/sveltekit/node_modules/@sveltejs/kit/src/runtime/server/index.js:295:5)
    at Object.handle (file:///C:/Users/dange/Documents/dev/sveltekit/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:343:66)
    at respond (file:///C:/Users/dange/Documents/dev/sveltekit/node_modules/@sveltejs/kit/src/runtime/server/index.js:292:40)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///C:/Users/dange/Documents/dev/sveltekit/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:413:22

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (16) x64 AMD Ryzen 9 5900HS with Radeon Graphics
    Memory: 8.55 GB / 15.41 GB
  Binaries:
    Node: 18.0.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.755.0), Chromium (107.0.1418.24), ChromiumDev ((@(&"C:/Users/dange/AppData/Local/Programs/oh-my-posh/bin/oh-my-posh.exe" init pwsh --config="C:\Users\dange\AppData\Local\Programs\oh-my-posh\themes\jandedobbeleer.omp.json" --print) -join "`n") | Invoke-Expression)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.85
    @sveltejs/kit: next => 1.0.0-next.528
    svelte: ^3.44.0 => 3.52.0
    vite: ^3.1.0 => 3.2.1

Severity

blocking all usage of SvelteKit

Additional Information

I can do a minimal reproduction, but I literally just start a new project and try to use form actions with use:enhance

@boian-ivanov
Copy link

boian-ivanov commented Oct 29, 2022

I've just about wanted to report this issue. I've been getting it on the root route +page.server.js/ts file, but I've been able to also replicate it with the default create-svelte app. Stackblitz link here.
In my experience if you have a +page.server.js/ts in the root of the routes, the /__data.json won't exist so it can't fetch any of the data that you are trying to pass at prerender. On full page load it works, but on prerender it doesn't. Seems like quite the braking issue.

Edit: This issue seems to only exists on server only routes. If you make the +page.server.js/ts to a +page.js/ts this doesn't seem to happen. But obviously you may need some API data on root that may require secret API keys.

Edit 2: as a momentary fix, I've been able to downgrade to 527 and the issue doesn't appear anymore. So I assume that it comes from the changes in this commit.

@JouanDeag
Copy link

Can confirm, getting this error as well.

@KarolusD
Copy link

Same here, reverting back to: "@sveltejs/kit": "1.0.0-next.527" helps.

@NormandoHall
Copy link

Same here

@chrskerr
Copy link
Contributor

chrskerr commented Oct 31, 2022

This appears to also impact invalidateAll(). We are receiving 404 errors on /__data.json, despite successful execution of both +layout.server.ts and +page.server.ts, which is causing a full page refresh.

@dummdidumm dummdidumm added bug Something isn't working p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc. labels Oct 31, 2022
@brandonp-ais
Copy link

Have the same issue, but was caused by having export const ssr = false in root +layout.server.ts file.

I could fix the problem by commenting out that line, or reverting to 527 as above.

@pheuter
Copy link

pheuter commented Oct 31, 2022

I'm seeing an issue now where the first request to __data.json fails and I have to click the link twice and the second request succeeds:

image

image

/cc @dummdidumm

@dummdidumm
Copy link
Member

Please open a new issue with a reproduction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants