Skip to content
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

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

miya
Copy link
Member

@miya miya commented Nov 26, 2024

Task

  • #158072 「マークダウン形式でページをエクスポート」が機能しない

@miya miya requested a review from yuki-takei November 26, 2024 09:24
@miya miya self-assigned this Nov 26, 2024
Copy link

changeset-bot bot commented Nov 26, 2024

⚠️ No Changeset found

Latest commit: b0db9da

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -761,7 +761,14 @@ module.exports = (crowi) => {
};
await crowi.activityService.createActivity(parameters);

return pipeline(stream, res);
Copy link
Member Author

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:

https://stackoverflow.com/questions/75118262/gulp-generates-typeerror-the-streams-property-must-be-of-type-function

Copy link
Member

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 を書く

mergify bot added a commit that referenced this pull request Nov 26, 2024
@mergify mergify bot merged commit e5891db into master Nov 26, 2024
22 checks passed
@mergify mergify bot deleted the fix/158086-failed-to-export-the-page-markdown branch November 26, 2024 10:53
@github-actions github-actions bot mentioned this pull request Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants