Giter Club home page Giter Club logo

remix-fastify's People

Contributors

cliffordfajardo avatar dalitroz avatar danreeves avatar dependabot[bot] avatar eadmundo avatar github-actions[bot] avatar jarrku avatar mcansh avatar nprbst avatar philipp-spiess avatar samialdury avatar vstreame avatar wtgtybhertgeghgtwtg avatar ziimakc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

remix-fastify's Issues

Doesn't work with remix 1.5.1

With remix 1.5.1 root GET request will return empty html.

I was able to narrow it down to this piece of code

  if (Buffer.isBuffer(response.body)) {
    // in 1.4.3 this block was called, worked fine
    reply.send(response.body);
  } else if ((_response$body = response.body) !== null && _response$body !== void 0 && _response$body.pipe) {
    // in 1.5.1 this block not called because ` _response$body.pipe` is `undefined`
    response.body.pipe(reply.raw);
  } else {
    // in 1.5.1 this block is called and response body is empty
    reply.send();
  }

Syntax error when running tests

I'm using remix-fastify in my app but when I try to run my tests with Vitest I get this error:

SyntaxError: Unexpected token '.'
❯ new Script node:vm:100:7
❯ createScript node:vm:265:10
❯ Object.runInThisContext node:vm:313:10
❯ ../node_modules/@mcansh/remix-fastify/node_modules/glob/src/index.ts:1:28

I'm using typescript.

Remix v2 breaks remix-fastify

Fyi, just in case you're not already aware. Upgrading to remix v2 results in following error on startup:

[redacted]/node_modules/@mcansh/remix-fastify/dist/index.mjs:12
  AbortController,
  ^^^^^^^^^^^^^^^
SyntaxError: Named export 'AbortController' not found. The requested module '@remix-run/node' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

The "path" argument must be of type string. Received null

Windows
Node.js v18.14.2

"dependencies": {
    "@mcansh/remix-fastify": "^2.6.0",
    "@remix-run/node": "^1.14.1",
    "@remix-run/react": "^1.14.1",
    "fastify": "^4.14.1",
    "isbot": "^3.6.6",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  }
  1. npx create-remix@latest --template https://github.com/mcansh/remix-fastify/tree/main/example --no-install
  2. npm i
  3. npm run dev
PS D:\Data\code\test\my-remix-fastify-test> npm run dev

> dev
> npm run build && run-p dev:*


> build
> remix build

Building Remix app in production mode...
Built in 619ms

> dev:remix
> remix dev


> dev:server
> node --require dotenv/config --watch ./server.js

(node:1696) ExperimentalWarning: Watch mode is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
✅ app ready: http://0.0.0.0:3000
Loading environment variables from .env
node:internal/validators:163
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
    at new NodeError (node:internal/errors:399:5)
    at validateString (node:internal/validators:163:11)
    at resolve (node:path:167:9)
    at FSWatcher.<anonymous> (node:internal/watch_mode/files_watcher:94:30)
    at FSWatcher.emit (node:events:513:28)
    at FSWatcher._handle.onchange (node:internal/fs/watchers:215:12) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v18.14.2
💿 Built in 688ms
ERROR: "dev:server" exited with 1.

Failed running './server.js'

I am trying to run the unstable-vite template and I am getting the following...

> dev
> cross-env NODE_ENV=development node --watch-path ./server.js --enable-source-maps ./server.js

(node:27007) ExperimentalWarning: Watch mode is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Failed running './server.js'

AssertionError with example project

Hi there

I am testing the remix-fastify solution here and notice that the examlpe throws an AssertionError as soon as you build and run npm run start

I see the example was updated 6 days ago, this is without any changes to the code at all.
Any ideas?

AssertionError [ERR_ASSERTION]: The first character of a path should be `/` or `*`
    at Router.on (Q:\example\node_modules\find-my-way\index.js:107:3)
    at Object.addNewRoute (Q:\example\node_modules\fastify\lib\route.js:271:16)
    at Object.route (Q:\example\node_modules\fastify\lib\route.js:203:19)
    at Object.prepareRoute (Q:\example\node_modules\fastify\lib\route.js:142:18)
    at Object._get [as get] (Q:\example\node_modules\fastify\fastify.js:244:34)
    at remixFastify (Q:\example\node_modules\@mcansh\remix-fastify\src\plugin.ts:71:13)
    at Plugin.exec (Q:\example\node_modules\avvio\plugin.js:130:19)
    at Boot.loadPlugin (Q:\example\node_modules\avvio\plugin.js:272:10)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}

useLoaderData parsing error

Idk exactly whats going on, but useLoaderData can't parse my root loader json data after the first loading. It's serializable and works great with the official express runtime.

Returned loader data is identical btw, weird error.

Started to happen when I upgraded remix deps to 1.7.6

Error importing @remix-run/dev/server-build in example

When running remix using the example server.ts implementation provided here I get the following error on startup when it tries to import @remix-run/dev/server-build.

Error: @remix-run/dev/server-build is not meant to be used directly from node_modules. It exists to provide type definitions for a virtual module provided by the Remix compiler at build time.

From what I can tell this behaviour has been present in Remix for some time so i'm wondering whether i'm doing something wrong in my usage.

Add h2c support

https://fastify.dev/docs/latest/Reference/HTTP2/

At the moment, if I set:

const app = fastify({
  http2: true,
});

Then when I am passing

const handler = createRequestHandler({..});

return handler(request, reply);

I am getting an error:

Argument of type 'FastifyRequest<RouteGenericInterface, Http2Server, Http2ServerRequest, FastifySchema, FastifyTypeProviderDefault, unknown, FastifyBaseLogger, ResolveFastifyRequestType<...>>' is not assignable to parameter of type 'FastifyRequest<RouteGenericInterface, RawServerDefault, IncomingMessage, FastifySchema, FastifyTypeProviderDefault, unknown, FastifyBaseLogger, ResolveFastifyRequestType<...>>'.
  Type 'Http2ServerRequest' is missing the following properties from type 'IncomingMessage': headersDistinct, trailersDistinctts(2345)
(parameter) request: FastifyRequest<RouteGenericInterface, Http2Server, Http2ServerRequest, FastifySchema, FastifyTypeProviderDefault, unknown, FastifyBaseLogger, ResolveFastifyRequestType<...>>

Seems to be just type error.

App server coordination

Hey, remix v1.16 requires custom app servers to coordinate with dev server broadcasting via broadcastDevReady. Will this plugin do it in the background or I need to call it on my server file?

fixes for remix + 1.5.0

diff --git a/node_modules/@mcansh/remix-fastify/dist/server.js b/node_modules/@mcansh/remix-fastify/dist/server.js
index 8662102..fb5477f 100644
--- a/node_modules/@mcansh/remix-fastify/dist/server.js
+++ b/node_modules/@mcansh/remix-fastify/dist/server.js
@@ -1,5 +1,3 @@
-'use strict';
-
 Object.defineProperty(exports, '__esModule', { value: true });
 
 var node = require('@remix-run/node');
@@ -66,8 +64,14 @@ function createRemixRequest(request) {
 }
 async function sendRemixResponse(reply, nodeResponse) {
   reply.status(nodeResponse.status);
-  let multiValueHeaders = nodeResponse.headers.raw();
-  reply.headers(multiValueHeaders);
+
+  for (let [key, values] of Object.entries(nodeResponse.headers.raw())) {
+    if (key.toLowerCase() === 'set-cookie') {
+      reply.raw.setHeader(key, values);
+    } else {
+      reply.raw.setHeader(key, values.join('; '));
+    }
+  }
 
   if (nodeResponse.body) {
     await node.writeReadableStreamToWritable(nodeResponse.body, reply.raw);

Server side code doesn't get invalidated (new dev server)

Hello.

Recently I started using the new dev server with --no-restart and tweaked my server module to notify the remix dev server when the build changes.
server.ts:

import {  remixFastifyPlugin } from "@mcansh/remix-fastify";
import { broadcastDevReady } from "@remix-run/server-runtime";
import chokidar from "chokidar";
import fastify from "fastify";
import path from "path";
import { pathToFileURL } from "url";

const port = process.env.PORT ? +process.env.PORT : 3000;

const MODE = process.env.NODE_ENV;
const BUILD_FILE_PATH = path.join(process.cwd(), "build", "index.js");
const BUILD_FILE_URL = pathToFileURL(BUILD_FILE_PATH).href;

let update = Date.now();

const getLatestBuild = () => import(`${BUILD_FILE_URL}?update=${update}`);

async function notifyRemixServerIsReady() {
  update = Date.now();
  const build = await getLatestBuild();
  broadcastDevReady(build);
}

const app = fastify();

await app.register(remixFastifyPlugin, {
  build: await getLatestBuild(),
  mode: MODE,
});

app.listen({ port, host: "0.0.0.0" }, (_err, address) => {
  console.info(`Fastify server listening at ${address}`);

  if (MODE === "development") {
    notifyRemixServerIsReady();
  }
});

if (MODE === "development") {
  const watcher = chokidar.watch(
    `${path.dirname(BUILD_FILE_PATH).replace(/\\/g, "/")}/**.*`,
  );

  watcher.on("all", () => {
    notifyRemixServerIsReady();
  });
}

For some reason the newer build is not loaded by the plugin.
A reproduction repo: https://github.com/lu-zen/remix-fastify-require-cache

pnpm complains missing peer reps

I'm getting this error right out of the hole with clean remix template using express, which performing manual install using pnpm. No issues w/ npm.

 WARN  Issues with peer dependencies found
.
└─┬ @mcansh/remix-fastify 2.7.3
  ├── ✕ missing peer @remix-run/router@^1.5.0
  └── ✕ missing peer fastify@"^3.29.0 || ^4.0.0"
Peer dependencies that should be installed:
  @remix-run/router@^1.5.0     fastify@"^3.29.0 || ^4.0.0"  

package.json

{
  "private": true,
  "sideEffects": false,
  "scripts": {
    "build": "remix build",
    "dev": "npm-run-all build --parallel \"dev:*\"",
    "dev:node": "cross-env NODE_ENV=development nodemon --require dotenv/config ./server.js --watch ./server.js",
    "dev:remix": "remix watch",
    "start": "cross-env NODE_ENV=production node ./server.js",
    "typecheck": "tsc",
    "aws:bundle": "grunt bundle"
  },
  "dependencies": {
    "@mcansh/remix-fastify": "^2.7.3",
    "@remix-run/css-bundle": "^1.16.1",
    "@remix-run/express": "^1.16.1",
    "@remix-run/node": "^1.16.1",
    "@remix-run/react": "^1.16.1",
    "compression": "^1.7.4",
    "cross-env": "^7.0.3",
    "express": "^4.18.2",
    "isbot": "^3.6.8",
    "morgan": "^1.10.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "@remix-run/dev": "^1.16.1",
    "@remix-run/eslint-config": "^1.16.1",
    "@types/compression": "^1.7.2",
    "@types/express": "^4.17.17",
    "@types/morgan": "^1.9.4",
    "@types/react": "^18.0.35",
    "@types/react-dom": "^18.0.11",
    "dotenv": "^16.0.3",
    "eslint": "^8.38.0",
    "grunt": "^1.6.1",
    "grunt-contrib-clean": "^2.0.1",
    "grunt-contrib-copy": "^1.0.0",
    "grunt-exec": "^3.0.0",
    "nodemon": "^2.0.22",
    "npm-run-all": "^4.1.5",
    "typescript": "^5.0.4"
  },
  "engines": {
    "node": ">=14"
  }
}

useLoaderData() returns string value after recent update

I've been having some troubles in my small app after updating from 2.3.1 to 2.4.0. I noticed that during route transitions, the loader data would no longer properly deserialize resulting in the useLoaderData() hook returning a string instead of the object.

This is really puzzeling part is that there is only one change in this library (e2b4224) which does not seem related to how the JSON payloads are handled in the slightest.

Yet, this is the diff that I can apply to reproduce the issue 🤔 It seems like no other transitive dependencies have changed for me either.

diff --git a/package.json b/package.json
index 9f72b25..493ff5c 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +14,7 @@
   },
   "dependencies": {
     "@code-hike/lighter": "^0.3.4",
-    "@mcansh/remix-fastify": "2.3.1",
+    "@mcansh/remix-fastify": "2.4.0",
     "@prisma/client": "^4.10.0",
     "@radix-ui/react-dropdown-menu": "^2.0.2",
     "@radix-ui/react-tooltip": "^1.0.3",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4ffca2e..4513092 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -2,7 +2,7 @@ lockfileVersion: 5.4
 
 specifiers:
   '@code-hike/lighter': ^0.3.4
-  '@mcansh/remix-fastify': 2.3.1
+  '@mcansh/remix-fastify': 2.4.0
   '@octokit/graphql-schema': ^13.2.0
   '@prisma/client': ^4.10.0
   '@radix-ui/react-dropdown-menu': ^2.0.2
@@ -34,7 +34,7 @@ specifiers:
 
 dependencies:
   '@code-hike/lighter': 0.3.4
-  '@mcansh/remix-fastify': 2.3.1_5gckvsvob3hapzq4izcu2nl2ve
+  '@mcansh/remix-fastify': 2.4.0_5gckvsvob3hapzq4izcu2nl2ve
   '@prisma/client': [email protected]
   '@radix-ui/react-dropdown-menu': 2.0.2_5ndqzdd6t4rivxsukjv3i3ak2q
   '@radix-ui/react-tooltip': 1.0.3_5ndqzdd6t4rivxsukjv3i3ak2q
@@ -1948,8 +1948,8 @@ packages:
     engines: {node: '>=8'}
     dev: false
 
-  /@mcansh/remix-fastify/2.3.1_5gckvsvob3hapzq4izcu2nl2ve:
-    resolution: {integrity: sha512-gOeHayYhjgky4TxSaCUretrH03do4mwhgKRq8/OCRePie/S+66BfWsCHPIx3b4YjkrukfbqXK6qG8dYc/0BDUw==}
+  /@mcansh/remix-fastify/2.4.0_5gckvsvob3hapzq4izcu2nl2ve:
+    resolution: {integrity: sha512-JN4U48lPj3XGruNUvteIbc0h4ymdhb8UhQi5W5a5tnsl4vr7O4jwLXg4fRec33ptFdx4TkITgYr4TrZDbnqeEQ==}
     peerDependencies:
       '@remix-run/node': ^1.6.0
       fastify: ^3.29.0 || ^4.0.0

Depfu Error: Depfu is stuck and needs your help

Hello,

⚠️ We're getting errors with this repo and have given up after trying several times.

In most cases that means something is wrong with your current Npm setup and we can't fix it automatically:

• Error details:
NPM Error: npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@remix-run%2fnode - Not found
npm ERR! 404 
npm ERR! 404  '@remix-run/[email protected]' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /app/.npm/_logs/2021-09-22T08_03_55_954Z-debug.log

• Error details:
NPM Error: npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@remix-run%2fnode - Not found
npm ERR! 404 
npm ERR! 404  '@remix-run/[email protected]' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /app/.npm/_logs/2021-09-21T08_02_24_032Z-debug.log

• Error details:
NPM Error: npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@remix-run%2fnode - Not found
npm ERR! 404 
npm ERR! 404  '@remix-run/[email protected]' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /app/.npm/_logs/2021-09-20T07_42_09_944Z-debug.log

After you've fixed the problem, please activate this project again in the Depfu Dashboard.

👉 We will not send you further PRs until this is fixed and the repo is activated again.

If you need help or this looks like an error on our side, please send us an email.

Issue with dependencies

I followed the instructions to create a remix project with remix-fastify template but I got an error when I tried to install the dependencies.
The problem is that @mcansh/remix-fastify comes with workspace:* as version. I tried both npm install and yarn, but they fail to install due to not recognizing the version (screenshots below). I know the fix is just edit package.json and put the version on the lib, but this can be confusing for unexperienced developers who are trying to use this lib.

npm install
image

yarn
image

The other thing I noticed is that the isbot lib is listed as a dependency, but it's not used anywhere in the example code, so I believe it could be removed.
image

I'd be happy to open a PR to make the changes, let me know what you think.

Depfu Error: Depfu is stuck and needs your help

Hello,

⚠️ We're getting errors with this repo and have given up after trying several times.

In most cases that means something is wrong with your current Npm setup and we can't fix it automatically:

• Error details:
NPM Error: npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@remix-run%2fnode - Not found
npm ERR! 404 
npm ERR! 404  '@remix-run/[email protected]' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /app/.npm/_logs/2021-09-24T15_25_55_361Z-debug.log

• Error details:
NPM Error: npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@remix-run%2fnode - Not found
npm ERR! 404 
npm ERR! 404  '@remix-run/[email protected]' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /app/.npm/_logs/2021-09-23T14_50_01_805Z-debug.log

• Error details:
NPM Error: npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@remix-run%2fnode - Not found
npm ERR! 404 
npm ERR! 404  '@remix-run/[email protected]' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /app/.npm/_logs/2021-09-22T15_02_48_518Z-debug.log

After you've fixed the problem, please activate this project again in the Depfu Dashboard.

👉 We will not send you further PRs until this is fixed and the repo is activated again.

If you need help or this looks like an error on our side, please send us an email.

release commenting

jobs:
  comment:
    name: 📝 Comment on issues and pull requests
    if: github.repository == 'mcansh/remix-fastify'
    runs-on: ubuntu-latest
    steps:
      - name: ⬇️ Checkout repo
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: 📝 Comment on issues
        uses: mcansh/[email protected]
        env:
          DIRECTORY_TO_CHECK: "./packages"
          PACKAGE_VERSION_TO_FOLLOW: "@mcansh/remix-fastify"
          GITHUB_REPOSITORY: ${{ github.repository }}
          GH_TOKEN: ${{ github.token }}

Remix fastify setup questions

After installing remix-fastify like so:

npm i @mcansh/remix-fastify

what are the next steps?
I took a look at your /example folder and it looks the setup instructions would be like this:

  1. Install a standard remix app like Remix App Server
  2. Install npm i @mcansh/remix-fastify
  3. create a server.ts file at the root and use @mcansh/remix-fastify?

Cannot set headers after they are sent to the client

Hi.

I'm using remix-fastify with streaming hydration, and sometimes I got this error:

Error: Cannot set headers after they are sent to the client
    at new NodeError (node:internal/errors:393:5)
    at ServerResponse.setHeader (node:_http_outgoing:644:11)
    at ServerResponse.writeHead (node:_http_server:377:21)
    at onSendEnd (node_modules/fastify/lib/reply.js:598:7)
    at onSendHook (node_modules/fastify/lib/reply.js:529:5)
    at fallbackErrorHandler (node_modules/fastify/lib/error-handler.js:130:3)
    at handleError (node_modules/fastify/lib/error-handler.js:60:5)
    at onErrorHook (node_modules/fastify/lib/reply.js:699:5)
    at _Reply.Reply.send (node_modules/fastify/lib/reply.js:133:5)
    at defaultErrorHandler (node_modules/fastify/lib/error-handler.js:91:9)

My server file is identical to the example/server.js, my entry.server.ts file is like this

Should there be a start:dev script?

After running npx create-remix@latest --template https://github.com/mcansh/remix-fastify/tree/main/example --no-install, per the README we should run npm run dev and npm run start:dev. Should there be a start:dev script? What am I missing here?

Question (Vite Remix example) Purpose of serving `build/client` directory?

The example of Vite Remix set up @fastify/static to serve the entire build/client directory in addition to build/client/assets regardless of process.env.NODE_ENV.

await app.register(fastifyStatic, {
root: path.join(__dirname, "build", "client"),
prefix: "/",
wildcard: false,
cacheControl: true,
dotfiles: "allow",
etag: true,
maxAge: "1h",
serveDotFiles: true,
lastModified: true,
});

As far as I can tell, at least with Vite Remix setup, build command does not create additional files in build/client other than what's inside build/client/assets and it seems to be pointless. What is the purpose of this static serve setup?

Why is noopContentParser needed?

const noopContentParser: FastifyContentTypeParser = (
  _request,
  payload,
  done,
) => {
  done(null, payload);
};

app.addContentTypeParser('application/json', noopContentParser);
app.addContentTypeParser('*', noopContentParser);

Just wondering what purpose this serves

Posting "application/json" using fetcher not working

Remix v.1.18.0 added support for JSON/Test submissions. For example:

      <button
        onClick={() => {
          fetcher.submit(
            { foo: "bar" },
            {
              method: "POST",
              action: "/test",
              encType: "application/json",
            }
          );
        }}
      >
        test
      </button>

For action on same route:

export const action = async ({ request }: ActionArgs) => {
  console.log(await request.json());
  return null;
};

Works as expected on Express (prints JSON to console):
/Users/roland/GitHub/public/remix/remix-express <== works

However, same client code and action fail when using Remix Fastify adapter:
/Users/roland/GitHub/public/remix/remix-fastify <== fails

Even though shouldn't be needed for Fastify (parses application/json by default), added contentTypeParser to server.mjs anyway but didn't help (but did see the json string being proceeded inside when logged).

The \"path\" argument must be of type string. Received undefined

On server start following error is thrown The \"path\" argument must be of type string. Received undefined

For server like:

  await app.register(remixFastifyPlugin, {
    build: path.join(__dirname, '../build/index.js'), // resolves fine
    mode: isDev ? 'development' : 'production',
  });

Error happens in this file: node_modules/@mcansh/remix-fastify/plugin.js

let remixFastify = async (fastify, options = {}) => {
  let {build, mode = process.env.NODE_ENV} = options;
  (0, import_tiny_invariant.default)(build, "You must provide a build");

  console.error(build)  // resolves fine to D:\apps\xx\frontend\build\index.js
  console.error(typeof build === "string" ) // true
  console.error(resolvedBuild) // {}


  let resolvedBuild = typeof build === "string" ? require(build) : build;  // require(build) resolves to {}

  if (!fastify.hasContentTypeParser("*")) {
    fastify.addContentTypeParser("*", (_request, payload, done) => {
      done(null, payload);
    });
  }
  fastify.register(import_fastify_racing.default, {handleError: true});
  let ROOT_DIR = process.cwd();
  let PUBLIC_DIR = path.join(ROOT_DIR, "public");
  let ASSET_DIR = path.join(ROOT_DIR, resolvedBuild.assetsBuildDirectory); // resolvedBuild.assetsBuildDirectory is undefined - error

Promise may not be fulfilled

Fastify logs error:

[20:25:17.890] ERROR: Promise may not be fulfilled with 'undefined' when statusCode is not 204 {"reqId":"req-1"}
    err: {
      "type": "FastifyError",
      "message": "Promise may not be fulfilled with 'undefined' when statusCode is not 204",
      "stack":
          FastifyError: Promise may not be fulfilled with 'undefined' when statusCode is not 204
              at D:\apps\pandahub\node_modules\.pnpm\[email protected]\node_modules\fastify\lib\wrapThenable.js:30:30
              at processTicksAndRejections (node:internal/process/task_queues:96:5)
      "name": "FastifyError",
      "code": "FST_ERR_PROMISE_NOT_FULFILLED",
      "statusCode": 500
    }

because:

  if (nodeRes.body) {
    await writeReadableStreamToWritable(nodeRes.body, reply.raw);
    // fastify.sent is false
    // fastify.send() not called
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.