-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix(payments-plugin): Stripe controller crashes server instance #2454
Conversation
✅ Deploy Preview for effervescent-donut-4977b2 canceled.
|
Ok, now I fixed the issue (hope it will work for everybody else as well) import { json } from 'body-parser';
import * as http from 'http';
import { RequestWithRawBody } from './types';
/**
* Middleware which adds the raw request body to the incoming message object. This is needed by
* Stripe to properly verify webhook events.
*/
export const rawBodyMiddleware = json({
type: '*/*',
verify(req: RequestWithRawBody, res: http.ServerResponse, buf: Buffer, encoding: string) {
if (Buffer.isBuffer(buf)) {
req.rawBody = Buffer.from(buf);
}
return true;
},
}); |
…ipeController's return logic
Ok, the previos solution doesn't work (thankfully, the E2E tests catched it in time!) @michaelbromley do you have any tips how I can solve that? |
Ok, now it seems to be working! :) |
Thank you for the considerable work you must have put in for this investigation & fix! 🙏 |
This patch is slightly related to the issue 2450, but fixes only the crash side of it:
I've put the last
response.status(HttpStatus.OK).send('Ok')
to the transaction block, otherwise it crashes the backend with the following error:Please note that this does not solves the issue that the
rawBody
is not defined because the middleware is not executed, but at least the backend won't crash because of any unidentified issues.