Skip to content

Error 500 in sverdle on demo app #85

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

Closed
victorhugoturnes opened this issue Oct 17, 2022 · 14 comments
Closed

Error 500 in sverdle on demo app #85

victorhugoturnes opened this issue Oct 17, 2022 · 14 comments

Comments

@victorhugoturnes
Copy link

Internal server error on sverdle page

@FlippingBinary
Copy link
Contributor

FlippingBinary commented Oct 18, 2022

Some context would be helpful, but this is probably due to issue #83. Are you able to test PR #84 to see if the problem persists?

@FlippingBinary
Copy link
Contributor

It's working fine in my environment, so I'm having trouble identifying what the problem could be. #83 has no impact when you npm run dev and prevents deploying it, so that couldn't be the problem.

Did you pull the latest version from this repository? How did you build/run it? What does the browser console and terminal console report?

@victorhugoturnes
Copy link
Author

victorhugoturnes commented Oct 18, 2022

Sorry for the lack of context, it was late at night when I made the issue.

Using npm run dev works fine, but using azure client doesnt,

Full log from start and loading the sverdle page:
``swa start

Welcome to Azure Static Web Apps CLI (1.0.2)

Multiple configurations found in "swa-cli.config.json", but none was specified.
Specify which configuration to use with "swa --config-name "

Using configuration "app" from file:
/hidden_for_privacy/svelte-adapter-azure-swa/demo/swa-cli.config.json


  • WARNING: This emulator may not match the cloud environment exactly. *
  • Always deploy and test your app in Azure. *

[api] Can't determine project language from files. Please use one of [--csharp, --javascript, --typescript, --java, --python, --powershell, --custom]
[api] Can't determine project language from files. Please use one of [--csharp, --javascript, --typescript, --java, --python, --powershell, --custom]
[api] Can't determine project language from files. Please use one of [--csharp, --javascript, --typescript, --java, --python, --powershell, --custom]
[api]
[api] Azure Functions Core Tools
[api] Core Tools Version: 4.0.4829 Commit hash: N/A (64-bit)
[api] Function Runtime Version: 4.11.2.19273
[api]
[api] Can't determine project language from files. Please use one of [--csharp, --javascript, --typescript, --java, --python, --powershell, --custom]
[api] Can't determine project language from files. Please use one of [--csharp, --javascript, --typescript, --java, --python, --powershell, --custom]
[api] Can't determine project language from files. Please use one of [--csharp, --javascript, --typescript, --java, --python, --powershell, --custom]
[api] [2022-10-18T15:07:50.985Z] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
[api] For detailed output, run func with --verbose flag.
[swa]
[swa] Found configuration file:
[swa] /hidden_for_privacy/svelte-adapter-azure-swa/demo/build/staticwebapp.config.json
[swa]
[swa]
[swa] Serving static content:
[swa] /hidden_for_privacy/svelte-adapter-azure-swa/demo/build/static
[swa]
[swa] Serving API:
[swa] /hidden_for_privacy/svelte-adapter-azure-swa/demo/api
[swa]
[swa] Azure Static Web Apps emulator started at http://localhost:4280. Press CTRL+C to exit.
[swa]
[swa]
[api] [2022-10-18T15:07:55.934Z] Host lock lease acquired by instance ID '0000000000000000000000008F717027'.
[swa] GET http://localhost:7071/api/__render (proxy)
[swa] GET http://localhost:4280/api/__render - 404``

So the page loads normally on the home and about, but 500s on sverdle
image,

@FlippingBinary
Copy link
Contributor

Okay, thank you. That's good information. I think this is the relevant line:

[swa] GET http://localhost:4280/api/__render - 404``

It looks like npm run build either failed or was not executed. If it failed, it's probably due to #83 and will be fixed soon.

@geoffrich
Copy link
Owner

I don't think it would be #83, since I haven't released those changes yet (see #76). Did you do npm run build before swa start as stated in the README?

Run npm run build to build your project and swa start to start the emulator.

Right now you have to fully build the project to test with the SWA CLI. I'm not sure if there's a way around that.

@victorhugoturnes
Copy link
Author

The current master commit cant run npm run build because of #83, so I manually added the fix on the linked PR to get it to run, or else it fails on npm build, although it does work on npm run dev

@victorhugoturnes
Copy link
Author

victorhugoturnes commented Oct 18, 2022

Adding the block

			builder.copy(files, tmp, {
				replace: {
					SERVER: `${relativePath}/index.js`,
					MANIFEST: './manifest.js',
					DEBUG: debug.toString()
				}
			});


to the index file, instead of the fixes suggested on #83 changed the error, with it, it can be built and shows up the sverdle page, normally, but once you press the enter key it fails with NetworkError when attempting to fetch resource. and the following SWA log:

[swa] GET http://localhost:7071/api/__render (proxy)
[api] [2022-10-18T16:09:47.439Z] Executing 'Functions.render' (Reason='This function was programmatically called via the host APIs.', Id=2971b6f9-e4d9-4988-a8f3-29b735bc3d22)
[api] [2022-10-18T16:09:47.613Z] Executed 'Functions.render' (Succeeded, Id=2971b6f9-e4d9-4988-a8f3-29b735bc3d22, Duration=205ms)
[swa] GET http://localhost:4280/api/__render - 200
[swa] node "~/.nvm/versions/node/v16.16.0/lib/node_modules/@azure/static-web-apps-cli/dist/msha/server.js" exited with code 0
--> Sending SIGTERM to other processes..
[api] [2022-10-18T16:09:48.123Z] Language Worker Process exited. Pid=58208.
[api] [2022-10-18T16:09:48.123Z] node exited with code 143 (0x8F). .
[api] [2022-10-18T16:09:48.272Z] Worker process started and initialized.
[api] [2022-10-18T16:09:50.187Z] Host lock lease acquired by instance ID '0000000000000000000000008F717027'.

@FlippingBinary
Copy link
Contributor

What operating system are you using?

Do you get stuck in a redirect loop when you refresh the /sverdle page?

@victorhugoturnes
Copy link
Author

victorhugoturnes commented Oct 18, 2022

I'm currently using archlinux, node v16.16.0, swa-cli 1.0.2.

I've created another sveltekit sverdle app, and added the adapter, no problems in compilations and the page loads without problems, but swa client crashes on sverdle submit
here is the error log:

[swa] GET http://localhost:5173/src/routes/sverdle/+page.svelte?svelte&type=style&lang.css (proxy)
[swa] GET http://localhost:4280/src/routes/sverdle/+page.svelte?svelte&type=style&lang.css - 304
[swa] node "~/.nvm/versions/node/v16.16.0/lib/node_modules/@azure/static-web-apps-cli/dist/msha/server.js" exited with code 0
--> Sending SIGTERM to other processes..
[api] [2022-10-18T20:59:39.780Z] Language Worker Process exited. Pid=14075.
[api] [2022-10-18T20:59:39.780Z] node exited with code 143 (0x8F). .
[run] cd "~/svelte-demo" && npm run dev exited with code SIGTERM
--> Sending SIGTERM to other processes..
[api] [2022-10-18T20:59:39.842Z] Language Worker Process exited. Pid=14220.
[api] [2022-10-18T20:59:39.842Z] node exited with code 143 (0x8F). .
[api] [2022-10-18T20:59:49.986Z] Worker process started and initialized.
^C[api] [2022-10-18T21:00:54.323Z] Language Worker Process exited. Pid=14234.
[api] [2022-10-18T21:00:54.323Z] node exited with code 130 (0x82). .
[api] [2022-10-18T21:00:54.324Z] Exceeded language worker restart retry count for runtime:node. Shutting down and proactively recycling the Functions Host to recover
[api] cd "~/svelte-demo/api" && func start --cors "*" --port 7071  exited with code 0
✖ SWA emulator stoped because API server exited with code 0.

I've put this on the cloud, in the following link: link deprecated the project I used for this one is in my github, link deprecated.

Although on the cloud it doesnt crash, it returns 200 but doesnt update with the returned state of the sverdle, as in it resets the state of the page and ignores my submission.

@geoffrich
Copy link
Owner

I just deployed the local demo app in this repo (which uses the unreleased adapter version) to Azure SWA and it doesn't have the issue you described: https://polite-desert-00b80111e.2.azurestaticapps.net/sverdle

I suspect the error is related to #63 and cookies aren't being set correctly. This fix is in the main branch but not yet released. I'll cut a new release and see if that fixes it.

@geoffrich
Copy link
Owner

Can you try svelte-adapter-azure-swa v0.11 and see if that fixes the issue with your deployed demo?

@victorhugoturnes
Copy link
Author

v0.11 worked.

Deployed is working fine, but not on swa-cli (same server exit error from before), although at this point I think its the swa tool itself that is being troublesome, I'll try it in a windows environment tomorrow see if helps.

Thanks for all the support and help

@victorhugoturnes
Copy link
Author

Running the StackBlitz linked on the oficial svelteKit page is also erroring 500 on sverdle,
image

So I'm assuming the error is internal to svelte or svelte kit and not relating to the adapter at this point.

@geoffrich
Copy link
Owner

The stackblitz issue is CSRF related, see sveltejs/kit#7277. Though maybe the SWA CLI is having the same issue?

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

3 participants