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

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined #176

Closed
iamshz97 opened this issue Jun 2, 2024 · 4 comments

Comments

@iamshz97
Copy link

iamshz97 commented Jun 2, 2024

geoffrich really grateful for the adapter to deploy svelte to azure SWA it's amazing!

Running into an issue where as when I install @ethercorps/sveltekit-og and use it with swa start I get an internal server error

[swa] GET http://127.0.0.1:7071/api/__render (proxy)
[api] [2024-06-02T14:54:34.857Z] Executing 'Functions.sk_render' (Reason='This function was programmatically called via the host APIs.', Id=9bd621cb-2a8c-460d-ba8a-5368e2fa27cf)
[api] [2024-06-02T14:54:35.077Z] Executed 'Functions.sk_render' (Succeeded, Id=9bd621cb-2a8c-460d-ba8a-5368e2fa27cf, Duration=240ms)
[swa] GET http://localhost:4280/api/__render - 200
[swa] GET http://127.0.0.1:7071/api/__render (proxy)
[api] [2024-06-02T14:54:39.301Z] Executing 'Functions.sk_render' (Reason='This function was programmatically called via the host APIs.', Id=55873b90-562f-4964-9dca-7241e928e83b)
[api] [2024-06-02T14:54:39.362Z] TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
[api] [2024-06-02T14:54:39.362Z]     at new NodeError (node:internal/errors:405:5)
[api] [2024-06-02T14:54:39.362Z]     at validateString (node:internal/validators:162:11)
[api] [2024-06-02T14:54:39.362Z]     at join (node:path:429:7)
[api] [2024-06-02T14:54:39.362Z]     at node_modules/@vercel/og/dist/index.node.js (C:\Projects\frontendfun\hello-og\build\server\sk_render\index.js:22232:98)
[api] [2024-06-02T14:54:39.362Z]     at __init (C:\Projects\frontendfun\hello-og\build\server\sk_render\index.js:8:56)
[api] [2024-06-02T14:54:39.362Z]     at .svelte-kit/output/server/entries/endpoints/title/_server.ts.js (C:\Projects\frontendfun\hello-og\build\server\sk_render\index.js:22250:5)
[api] [2024-06-02T14:54:39.362Z]     at __init (C:\Projects\frontendfun\hello-og\build\server\sk_render\index.js:8:56)
[api] [2024-06-02T14:54:39.362Z]     at C:\Projects\frontendfun\hello-og\build\server\sk_render\index.js:25486:64
[api] [2024-06-02T14:54:39.362Z]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[api] [2024-06-02T14:54:39.362Z]     at async respond (C:\Projects\frontendfun\hello-og\build\server\sk_render\index.js:25119:22) {
[api] [2024-06-02T14:54:39.362Z]   code: 'ERR_INVALID_ARG_TYPE'
[api] [2024-06-02T14:54:39.362Z] Executed 'Functions.sk_render' (Succeeded, Id=55873b90-562f-4964-9dca-7241e928e83b, Duration=61ms)
[api] [2024-06-02T14:54:39.363Z] }

This issue only happens when I perform swa start + svelte-adapter-azure-swa , when I perform npm run dev works flawlessly

any clue on what might be the cause..... or maybe this is something we have to check with the author of @ethercorps/sveltekit-og?

Thank you in advance!!!

@geoffrich
Copy link
Owner

Can you provide a repo with a minimal reproduction?

@iamshz97
Copy link
Author

iamshz97 commented Jun 3, 2024

Much appreciated @geoffrich here's the project,

git clone https://github.com/iamshz97/shz-og-svelte

Once the project is cloned

  1. npm run dev
  • Navigate to path http://localhost:5173/generate-image
  1. npm run build && xcopy /E /I "function-configs" ".\build\server" && swa start
  • Navigate to path http://localhost:4280/generate-image
[api] [2024-06-03T18:22:32.980Z] Executing 'Functions.sk_render' (Reason='This function was programmatically called via the host APIs.', Id=70a5ce9c-e61b-4ee6-94bc-3026fa070f67)
[api] [2024-06-03T18:22:32.985Z] TypeError [ERR_INVALID_ARG_VALUE]: The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received undefined
[api] [2024-06-03T18:22:32.985Z]     at new NodeError (node:internal/errors:405:5)
[api] [2024-06-03T18:22:32.985Z]     at createRequire (node:internal/modules/cjs/loader:1505:11)
[api] [2024-06-03T18:22:32.986Z]     at node_modules/css-tree/lib/data-patch.js (C:\Projects\shz-og-svelte\build\server\sk_render\index.js:39671:48)
[api] [2024-06-03T18:22:32.986Z]     at __init (C:\Projects\shz-og-svelte\build\server\sk_render\index.js:8:56)
[api] [2024-06-03T18:22:32.986Z]     at node_modules/css-tree/lib/data.js (C:\Projects\shz-og-svelte\build\server\sk_render\index.js:39740:5)
[api] [2024-06-03T18:22:32.986Z]     at __init (C:\Projects\shz-og-svelte\build\server\sk_render\index.js:8:56)
[api] [2024-06-03T18:22:32.986Z]     at node_modules/css-tree/lib/syntax/config/lexer.js (C:\Projects\shz-og-svelte\build\server\sk_render\index.js:42232:5)
[api] [2024-06-03T18:22:32.986Z]     at __init (C:\Projects\shz-og-svelte\build\server\sk_render\index.js:8:56)
[api] [2024-06-03T18:22:32.986Z]     at node_modules/css-tree/lib/syntax/index.js (C:\Projects\shz-og-svelte\build\server\sk_render\index.js:42850:5)
[api] [2024-06-03T18:22:32.987Z]     at __init (C:\Projects\shz-og-svelte\build\server\sk_render\index.js:8:56) {
[api] [2024-06-03T18:22:32.987Z]   code: 'ERR_INVALID_ARG_VALUE'
[api] [2024-06-03T18:22:32.987Z] }
[api] [2024-06-03T18:22:32.988Z] Executed 'Functions.sk_render' (Succeeded, Id=70a5ce9c-e61b-4ee6-94bc-3026fa070f67, Duration=7ms)

My intention is to deploy this app in SWA + Azure managed function, therefore I can use this setup to have og images generated on the fly......

Using Svelte cause it's lightweight plus the adapter works perfectly fine & this issue comes up whenever a library that uses resvg/resvg-js is used also tried similar libraries & it throws similar errors. I'd like to dig deep on this but I'm primarily on .NET and fresh on node.

In addition, not sure would this help when I started using the adapter the project failed to build which I then ended up also doing

Issue

node_modules/@resvg/resvg-js/js-binding.js:1:1284: ERROR: No loader is configured for ".node" files: node_modules/@resvg/resvg-js-win32-x64-msvc/resvgjs.win32-x64-msvc.node
    at failureErrorWithLog (C:\Projects\shz-og-svelte\node_modules\svelte-adapter-azure-swa\node_modules\esbuild\lib\main.js:1651:15)
    at C:\Projects\shz-og-svelte\node_modules\svelte-adapter-azure-swa\node_modules\esbuild\lib\main.js:1059:25
    at C:\Projects\shz-og-svelte\node_modules\svelte-adapter-azure-swa\node_modules\esbuild\lib\main.js:1004:52
    at buildResponseToResult (C:\Projects\shz-og-svelte\node_modules\svelte-adapter-azure-swa\node_modules\esbuild\lib\main.js:1057:7)
    at C:\Projects\shz-og-svelte\node_modules\svelte-adapter-azure-swa\node_modules\esbuild\lib\main.js:1086:16
    at responseCallbacks.<computed> (C:\Projects\shz-og-svelte\node_modules\svelte-adapter-azure-swa\node_modules\esbuild\lib\main.js:704:9)
    at handleIncomingPacket (C:\Projects\shz-og-svelte\node_modules\svelte-adapter-azure-swa\node_modules\esbuild\lib\main.js:764:9)
    at Socket.readFromStdout (C:\Projects\shz-og-svelte\node_modules\svelte-adapter-azure-swa\node_modules\esbuild\lib\main.js:680:7)
    at Socket.emit (node:events:517:28)
    at addChunk (node:internal/streams/readable:368:12)

Fix

		adapter: azure({
			apiDir: './build/server',
			esbuildOptions: {
				external: ['@resvg/resvg-js']
			}
		})

@geoffrich
Copy link
Owner

Very weird error - I was able to fix it by adding "css-tree" to esbuildOptions.external as well.

adapter: azure({
	apiDir: './build/server',
	esbuildOptions: {
		external: ['@resvg/resvg-js', 'css-tree']
	}
})

This seems to be specific to the @ethercorps/sveltekit-og package. Someone fixed an error using the Node adapter in a similar way: etherCorps/sveltekit-og#44.

@geoffrich
Copy link
Owner

Ah, and the root cause is an issue in Svelte: sveltejs/svelte#9288

Either way, hopefully that config change should resolve it for you

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

2 participants