Skip to content

Commit 0be531a

Browse files
committed
chore: use form body parser in fastify app
1 parent 5875efe commit 0be531a

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

dev-packages/node-integration-tests/utils/index.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,12 @@ async function makeRequest(
118118
await axios.post(url, axiosConfig);
119119
}
120120
} catch (e) {
121-
// We sometimes expect the request to fail, but not the test.
122-
// So, we do nothing.
121+
// We sometimes expect the request to fail, but not the test, so we are just logging the error.
122+
// Beware though! There are also framework specific errors, e.g. fastify can give a 415 with
123+
// FST_ERR_CTP_INVALID_MEDIA_TYPE if handling of application/x-www-form-urlencoded is not configure
124+
// properly when building a test application / server. Errors of these kind can lead to requests
125+
// not actually hitting the handler, and so no tracing will be happenning. This in its turn will
126+
// most like make the test time out.
123127
logger.warn(e);
124128
}
125129
}

packages/remix/test/integration/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"start": "remix-serve build"
88
},
99
"dependencies": {
10+
"@fastify/formbody": "^7.4.0",
1011
"@mcansh/remix-fastify": "^3.2.2",
1112
"@remix-run/express": "1.17.0",
1213
"@remix-run/node": "1.17.0",

packages/remix/test/integration/test/server/utils/helpers.ts

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { createRequestHandler as createExpressRequestHandler } from '@remix-run/
55
import { wrapExpressCreateRequestHandler, wrapFastifyCreateRequestHandler } from '@sentry/remix';
66
import express from 'express';
77
import fastify from 'fastify';
8+
import formBody from '@fastify/formbody'
89

910
import { TestEnv } from '../../../../../../../dev-packages/node-integration-tests/utils';
1011

@@ -32,6 +33,7 @@ const runExpressApp = (adapter: Adapter.Builtin | Adapter.Express): Promise<http
3233

3334
const runFastifyApp = (): Promise<http.Server> => new Promise(res => {
3435
const app = fastify();
36+
app.register(formBody);
3537
// @ts-ignore
3638
app.all('*', adapters[Adapter.Fastify]({ build: require('../../../build') }));
3739
app.listen({port: 0}, (_err, _addr) => {

0 commit comments

Comments
 (0)