-
Notifications
You must be signed in to change notification settings - Fork 219
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: Failed to export the page markdown #9444
fix: Failed to export the page markdown #9444
Conversation
|
@@ -761,7 +761,14 @@ module.exports = (crowi) => { | |||
}; | |||
await crowi.activityService.createActivity(parameters); | |||
|
|||
return pipeline(stream, res); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
エラー内容
@growi/app:dev: 08:54:10.116Z ERROR growi:
@growi/app:dev: Unhandled Rejection: Promise: Promise {
@growi/app:dev: <rejected> TypeError: The "streams[stream.length - 1]" property must be of type function. Received an instance of ServerResponse
@growi/app:dev: at popCallback (node:internal/streams/pipeline:74:3)
@growi/app:dev: at pipeline (node:internal/streams/pipeline:185:37)
@growi/app:dev: at /workspace/growi/apps/app/src/server/routes/apiv3/page/index.ts:764:20
@growi/app:dev: at processTicksAndRejections (node:internal/process/task_queues:95:5) {
@growi/app:dev: code: 'ERR_INVALID_ARG_TYPE'
@growi/app:dev: }
@growi/app:dev: } Reason: TypeError: The "streams[stream.length - 1]" property must be of type function. Received an instance of ServerResponse
@growi/app:dev: at popCallback (node:internal/streams/pipeline:74:3)
@growi/app:dev: at pipeline (node:internal/streams/pipeline:185:37)
@growi/app:dev: at /workspace/growi/apps/app/src/server/routes/apiv3/page/index.ts:764:20
@growi/app:dev: at processTicksAndRejections (node:internal/process/task_queues:95:5) {
@growi/app:dev: code: 'ERR_INVALID_ARG_TYPE'
@growi/app:dev: }
@growi/app:dev: TypeError: The "streams[stream.length - 1]" property must be of type function. Received an instance of ServerResponse
@growi/app:dev: at popCallback (node:internal/streams/pipeline:74:3)
@growi/app:dev: at pipeline (node:internal/streams/pipeline:185:37)
@growi/app:dev: at /workspace/growi/apps/app/src/server/routes/apiv3/page/index.ts:764:20
@growi/app:dev: at processTicksAndRejections (node:internal/process/task_queues:95:5) {
@growi/app:dev: code: 'ERR_INVALID_ARG_TYPE'
@growi/app:dev: }
@growi/app:dev: ⨯ unhandledRejection: TypeError: The "streams[stream.length - 1]" property must be of type function. Received an instance of ServerResponse
@growi/app:dev: at popCallback (node:internal/streams/pipeline:74:3)
@growi/app:dev: at pipeline (node:internal/streams/pipeline:185:37)
@growi/app:dev: at /workspace/growi/apps/app/src/server/routes/apiv3/page/index.ts:764:20
@growi/app:dev: at processTicksAndRejections (node:internal/process/task_queues:95:5) {
@growi/app:dev: code: 'ERR_INVALID_ARG_TYPE'
@growi/app:dev: }
@growi/app:dev: ⨯ unhandledRejection: TypeError: The "streams[stream.length - 1]" property must be of type function. Received an instance of ServerResponse
@growi/app:dev: at popCallback (node:internal/streams/pipeline:74:3)
@growi/app:dev: at pipeline (node:internal/streams/pipeline:185:37)
@growi/app:dev: at /workspace/growi/apps/app/src/server/routes/apiv3/page/index.ts:764:20
@growi/app:dev: at processTicksAndRejections (node:internal/process/task_queues:95:5) {
@growi/app:dev: code: 'ERR_INVALID_ARG_TYPE'
@growi/app:dev: }
原因
stream.pipeline の最後の引数が関数である必要があるが、Express の ServerResponse のインスタンスが入っていたことが原因
解決策
下記の StackOverflow を参考に stream/promises の pipline を利用するように修正しました
StackOverflow
Solution 2
stream/promises exposes a promise-based version of pipeline which does not use a callback:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
後続ストーリーでやること
import { pipeline } from 'stream';
が必要になるケースはあるのか?- もしないのであれば、上記の import はエラーになるような custom eslint rule を書く
Task