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

solid-start-static adapter throws ERR_INVALID_ARG_TYPE( #285

Closed
LiQuidProQuo opened this issue Sep 25, 2022 · 3 comments
Closed

solid-start-static adapter throws ERR_INVALID_ARG_TYPE( #285

LiQuidProQuo opened this issue Sep 25, 2022 · 3 comments
Assignees
Labels
bug Something isn't working needs reproduction issue needs a reproduction

Comments

@LiQuidProQuo
Copy link
Contributor

repro steps

1. pnpm create solid
1.1 selected options: template:bare ssr:yes  typescript:yes

3. pnpm add -d solid-start-static

4. pnpm build

build log

solid-start build 
 version  0.1.0
 adapter  static

solid-start building client...
vite v3.1.3 building for production...
✓ 56 modules transformed.
dist/public/manifest.json                      0.93 KiB
dist/public/ssr-manifest.json                  2.39 KiB
dist/public/assets/_...404_.00985c49.js        0.56 KiB / gzip: 0.37 KiB
dist/public/assets/index.76b9a9c1.js           0.75 KiB / gzip: 0.44 KiB
dist/public/assets/entry-client.d870915a.css   0.37 KiB / gzip: 0.26 KiB
dist/public/assets/index.fdb6b3cf.css          0.30 KiB / gzip: 0.21 KiB
dist/public/assets/entry-client.d40d4aa7.js    32.01 KiB / gzip: 12.13 KiB
solid-start client built in: 1.704s

solid-start building server...
vite v3.1.3 building SSR bundle for production...
✓ 56 modules transformed.
.solid/server/manifest.json     0.18 KiB
.solid/server/entry-server.js   49.89 KiB
solid-start server built in: 688.97ms

/workspaces/start4/src/routes
node:internal/errors:856
  const err = new Error(message);
              ^

Error: Command failed: node /workspaces/start4/node_modules/.pnpm/solid-ssr@1.5.6/node_modules/solid-ssr/static/writeToDisk.mjs /workspaces/start4/.solid/server/server.js /workspaces/start4/dist/public/*404.html /*404 --trace-warnings
node:internal/fs/utils:887
  throw new ERR_INVALID_ARG_TYPE(
  ^

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
    at writeFile (node:fs:2160:5)
    at file:///workspaces/start4/node_modules/.pnpm/solid-ssr@1.5.6/node_modules/solid-ssr/static/writeToDisk.mjs:8:5
    at FSReqCallback.oncomplete (node:fs:196:23) {
  code: 'ERR_INVALID_ARG_TYPE'
}

    at ChildProcess.exithandler (node:child_process:400:12)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1093:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5) {
  code: 1,
  killed: false,
  signal: null,
  cmd: 'node /workspaces/start4/node_modules/.pnpm/solid-ssr@1.5.6/node_modules/solid-ssr/static/writeToDisk.mjs /workspaces/start4/.solid/server/server.js /workspaces/start4/dist/public/*404.html /*404 --trace-warnings',
  stdout: '',
  stderr: 'node:internal/fs/utils:887\n' +
    '  throw new ERR_INVALID_ARG_TYPE(\n' +
    '  ^\n' +
    '\n' +
    'TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined\n' +
    '    at writeFile (node:fs:2160:5)\n' +
    '    at file:///workspaces/start4/node_modules/.pnpm/solid-ssr@1.5.6/node_modules/solid-ssr/static/writeToDisk.mjs:8:5\n' +
    '    at FSReqCallback.oncomplete (node:fs:196:23) {\n' +
    "  code: 'ERR_INVALID_ARG_TYPE'\n" +
    '}\n'
}

package.json

{
  "name": "start4",
  "scripts": {
    "dev": "solid-start dev",
    "build": "solid-start build",
    "start": "solid-start start"
  },
  "type": "module",
  "devDependencies": {
    "solid-start-node": "^0.1.0",
    "typescript": "^4.8.3",
    "vite": "^3.1.0"
  },
  "dependencies": {
    "@solidjs/meta": "^0.28.0",
    "@solidjs/router": "^0.4.3",
    "solid-js": "^1.5.4",
    "solid-start": "^0.1.0",
    "solid-start-static": "^0.1.0",
    "undici": "^5.10.0"
  },
  "engines": {
    "node": ">=14"
  }
}
@LiQuidProQuo LiQuidProQuo changed the title **solid-start-static** throws ERR_INVALID_ARG_TYPE( solid-start-static throws ERR_INVALID_ARG_TYPE( Sep 25, 2022
@LiQuidProQuo LiQuidProQuo changed the title solid-start-static throws ERR_INVALID_ARG_TYPE( solid-start-static adapter throws ERR_INVALID_ARG_TYPE( Sep 25, 2022
@zaydek
Copy link

zaydek commented Sep 25, 2022

I found I can get a working build by doing the following steps:

  1. npm create solid@next
  2. Initialized as bare, ssr=false, ts=true
  3. npm i
  4. npm i --save-dev solid-start-static
  5. Open vite.config.ts, add adapter: "solid-start-static" and remove ssr: false (ssr: false must be removed)
  6. Comment out // import { HttpStatusCode } from "solid-start/server"; and {/* <HttpStatusCode code={404} /> */} from [...404].tsx

Then and only then can I build

{
  "name": "demo-solid-start-4",
  "scripts": {
    "dev": "solid-start dev",
    "build": "solid-start build",
    "start": "solid-start start"
  },
  "type": "module",
  "devDependencies": {
    "solid-start-node": "^0.1.0",
    "solid-start-static": "^0.1.0",
    "typescript": "^4.8.3",
    "vite": "^3.1.0"
  },
  "dependencies": {
    "@solidjs/meta": "^0.28.0",
    "@solidjs/router": "^0.4.3",
    "solid-js": "^1.5.4",
    "solid-start": "^0.1.0",
    "undici": "^5.10.0"
  },
  "engines": {
    "node": ">=14"
  }
}

@ghalle ghalle added the bug Something isn't working label Sep 25, 2022
@LiQuidProQuo
Copy link
Contributor Author

static entry generation, does not explicitly handles the 404 status code case ( see entry.js#L26 )
as a result the request returns undefined, which then fails as a valid data input in writeToDisk.js write call.

if 404 is explicitly handled in entry.js, and the content is returned, the static file generation
is *successful, with the exception that there are oddly two files 404.html and *404.html (is that expected?)

image

https://github.com/solidjs/solid-start/blob/main/packages/start-static/entry.js#L26-L28

- if (webRes.status === 200) {
+ if (webRes.status === 200 || webRes.status === 404) {

alternatively return response body for any status code(to cover more cases) except for the redirect handling.

@nksaraf nksaraf self-assigned this Oct 1, 2022
@ryansolid
Copy link
Member

ryansolid commented Dec 30, 2022

Can't reproduce: https://stackblitz.com/edit/github-ov6sy6

Possibly already fixed?

@ryansolid ryansolid added the needs reproduction issue needs a reproduction label Dec 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs reproduction issue needs a reproduction
Projects
None yet
Development

No branches or pull requests

5 participants