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

helper/ssg/index.test.tsx does not close well #2090

Closed
yusukebe opened this issue Jan 26, 2024 · 8 comments
Closed

helper/ssg/index.test.tsx does not close well #2090

yusukebe opened this issue Jan 26, 2024 · 8 comments
Labels

Comments

@yusukebe
Copy link
Member

What version of Hono are you using?

latest https://github.com/honojs/hono/tree/b98e85092474ebc11884fc76ddf27fb29365cea1

What runtime/platform is your app running on?

CI/main

What steps can reproduce the bug?

Run tests on CI.

What is the expected behavior?

Passed.

What do you see instead?

https://github.com/honojs/hono/actions/runs/7654663888/job/20880284814

Additional information

No response

@yusukebe yusukebe added the bug label Jan 26, 2024
@EdamAme-x
Copy link
Contributor

thanks.
As additional information I also encountered this within Gitpod.io.

@EdamAme-x
Copy link
Contributor

However, there seem to be times when it fails and times when it succeeds.

@EdamAme-x
Copy link
Contributor

It also occurred here.
#2087

@watany-dev
Copy link
Contributor

@yusukebe @EdamAme-x
After checking the vitest community, it appears that with the default pools:threads, the test may become unstable and fail.
I was able to confirm errors like this one.
vitest-dev/vitest#5047

As a suggestion, how about putting pool: 'forks' in vitest.config.ts and WATCH to see if this case is resolved? I have tried this locally and so far it has not reoccurred.

@yusukebe
Copy link
Member Author

yusukebe commented Jan 27, 2024

It may be that the problem is not on the test side, but on the code side.

I'm still investigating, but the following changes will stop the hang.

diff --git a/src/helper/ssg/index.ts b/src/helper/ssg/index.ts
index 721eb9f..b4a0af6 100644
--- a/src/helper/ssg/index.ts
+++ b/src/helper/ssg/index.ts
@@ -140,7 +140,7 @@ export const fetchRoutesContent = async <

     for (const param of forGetInfoURLRequest.ssgParams) {
       const replacedUrlParam = replaceUrlParam(route.path, param)
-      let response = await app.request(replacedUrlParam, forGetInfoURLRequest)
+      let response = await app.request(new URL(replacedUrlParam, baseURL))
       if (afterResponseHook) {
         const maybeResponse = afterResponseHook(response)
         if (!maybeResponse) continue

I suspect that performing fetch twice on a single request object.

await app.fetch(forGetInfoURLRequest)

let response = await app.request(replacedUrlParam, forGetInfoURLRequest)

@yusukebe
Copy link
Member Author

Sending a request twice is not a good implementation, so I am trying to figure out a way to do ssgParams but not make the request.

@yusukebe
Copy link
Member Author

@watany-dev

You are right, we should merge #2098 first so that the test does not hang.

@yusukebe
Copy link
Member Author

@watany-dev

Thanks for investigating and the PR. Since the test no longer hangs, we can close this Issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants