Skip to content

Regression in Formidable v3, which can crash a server #958

@laurent22

Description

@laurent22

Using Formidable 3.5.1

Since we upgraded from v2 to Formidable v3, our server is crashing every few days, always with these errors:

server_1  | 2023-10-29 10:08:51: [error] App: 174.194.132.166 FormidableError: Could not parse form: Request aborted
server_1  |     at IncomingMessage.<anonymous> (/home/joplin/packages/server/node_modules/formidable/dist/index.cjs:1223:21)
server_1  |     at IncomingMessage.emit (node:events:517:28)
server_1  |     at IncomingMessage._destroy (node:_http_incoming:224:10)
server_1  |     at _destroy (node:internal/streams/destroy:109:10)
server_1  |     at IncomingMessage.destroy (node:internal/streams/destroy:71:5)
server_1  |     at abortIncoming (node:_http_server:766:9)
server_1  |     at socketOnClose (node:_http_server:760:3)
server_1  |     at Socket.emit (node:events:529:35)
server_1  |     at TCP.<anonymous> (node:net:350:12) {
server_1  |   code: 1002,
server_1  |   httpCode: 500
server_1  | }

Followed by this one:

server_1  | Error: Cannot call write after a stream was destroyed
server_1  |     at new NodeError (node:internal/errors:405:5)
server_1  |     at node:internal/fs/streams:406:23
server_1  |     at FSReqCallback.wrapper [as oncomplete] (node:fs:829:5)
ubuntu_server_1 exited with code 1

And the server crashes.

The code to parse the form content is relatively straightforward:

https://github.com/laurent22/joplin/blob/49c1c9aa652aff50560ab5f46c9bcdfccbac6409/packages/server/src/utils/requestUtils.ts#L73

As I understand the error happens in an internal stream handler, which means it's impossible to catch and ends up crashing the server. I have searched about this error message and I see that it was addressed in v1.x, but it definitely seems to be back. We didn't have this crash when using Formidable v1 or v2, but a few days after we upgraded to v3 it started happening.

Any idea if something can be done about it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: streamsThings related to handling streams, and bugs around them.Priority: MediumThis issue may be useful, and needs some attention.Status: AvailableNo one has claimed for resolving this issue. Generally applied to bugs and enhancement issues.Type: BugInconsistencies or issues which will cause an issue or problem for users or implementors.bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions