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: Automatic installation failure #8685

Merged
merged 11 commits into from
Apr 5, 2024
Merged

Conversation

miya
Copy link
Member

@miya miya commented Apr 4, 2024

Task

#138561 [VRT] 正常化残タスク
#144073 Auto Install 時のエラー修正

@miya miya requested a review from yuki-takei April 5, 2024 02:39
@miya miya changed the title fix: Unable to login in Cypress test fix: Automatic installation failure Apr 5, 2024
@@ -503,6 +501,8 @@ Crowi.prototype.start = async function() {
// Execute this asynchronously after the express server is ready so it does not block the ongoing process
this.asyncAfterExpressServerReady();

this.autoInstall();

return serverListening;
};

Copy link
Member Author

@miya miya Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

症状

auto install 時にエラーが出ていて自動生成されるはずの user が作成できていませんでした。cypress テストでログインが必要な操作はこれが原因で失敗しているようでした。

エラーログ

[2024-04-04T13:28:32.170Z] ERROR: growi:service:installer/3304 on fv-az1493-626: Http server has not attached yet.
  Error: Http server has not attached yet.
      at SocketIoService.getDefaultSocket (/home/runner/work/growi/growi/apps/app/dist/server/service/socket-io.js:45:19)
      at PageService.emitUpdateDescCount (/home/runner/work/growi/growi/apps/app/dist/server/service/page/index.js:2784:51)
      at PageService.updateDescendantCountOfAncestors (/home/runner/work/growi/growi/apps/app/dist/server/service/page/index.js:2781:14)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async PageService.forceCreateBySystem (/home/runner/work/growi/growi/apps/app/dist/server/service/page/index.js:3204:9)
      at async InstallerService.install (/home/runner/work/growi/growi/apps/app/dist/server/service/installer.js:99:13)

https://github.com/weseek/growi/actions/runs/8555429794/job/23442998304#step:17:168

原因

以下の処理で pageService.forceCreateBySystem というメソッドを使っていおり、内部で socketIoService に依存しています。

await this.createPage(
path.join(this.crowi.localeDir, globalLang, 'welcome.md'),
'/',

依存している socketIoService の初期化処理よりも前に autoInstall() を実行していたことがバグの原因でした。

以下の PR で初回ページの作成ロジックが pageService.create() から pageService.forceCreateBySystem() に変更されていました。
https://github.com/weseek/growi/pull/8459/files#diff-8d6a6a68e7b9af0c58501e40918527ae36b391e965e1a850f37bc78ea7323c15R56

解決策

socketIoService の初期化、SocketIoService.attachServer() の実行後に autoInstall() するように修正しました。

@@ -503,6 +501,8 @@ Crowi.prototype.start = async function() {
// Execute this asynchronously after the express server is ready so it does not block the ongoing process
this.asyncAfterExpressServerReady();

this.autoInstall();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

listen する前にデータ作成完了させておきたい

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修正しました

Copy link

reg-suit bot commented Apr 5, 2024

✨✨ That's perfect, there is no visual difference! ✨✨

Check out the report here.

@miya miya merged commit 0c49cfb into master Apr 5, 2024
21 of 29 checks passed
@miya miya deleted the fix/unable-to-login-using-cypress branch April 5, 2024 08:20
@github-actions github-actions bot mentioned this pull request Apr 5, 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