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

fastify.inject timeout when @fastify/nextjs is registered #748

Open
2 tasks done
joshuaavalon opened this issue May 12, 2023 · 4 comments
Open
2 tasks done

fastify.inject timeout when @fastify/nextjs is registered #748

joshuaavalon opened this issue May 12, 2023 · 4 comments
Labels
bug Confirmed bug

Comments

@joshuaavalon
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.17.0

Plugin version

9.2.0

Node.js version

v20.1.0

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

10

Description

When I run unit tests by fastify.inject, it timeout after several requests.

- event compiled client and server successfully in 639 ms (151 modules)
      1) should create user with admin role
- event compiled client and server successfully in 311 ms (151 modules)
      ✔ should create normal user (1291ms)
    login
      2) should login admin user
      3) should login normal user
    me
      4) should return admin user
      5) should return normal user


  1 passing (11s)
  5 failing

  1) User
       createUser
         should create user with admin role:
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (C:\Users\user\project\git\api2\dist\__tests__\index.js)
      at listOnTimeout (node:internal/timers:573:17)
      at process.processTimers (node:internal/timers:514:7)

Steps to Reproduce

I run test with the following

server.inject({
  method: "POST",
  url: "/graphql",
  payload: { query: print(documentNode), variables },
  headers: authToken
    ? { authorization: `Bearer ${authToken}` }
    : undefined
});

Expected Behavior

The tests do not timeout

@mcollina
Copy link
Member

Thanks for reporting!

Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.

@joshuaavalon
Copy link
Author

joshuaavalon commented May 15, 2023

Example: https://github.com/joshuaavalon/fastify-nextjs-bug

  1. npm i
  2. npm run start

Expect the script to stop after 1 is print, however, it does not stop.

The expected behavior is what commenting out await app.register(nextPlugin); in index.js.

@mcollina
Copy link
Member

Apparently we have not tests using inject(), so it's likely possible this would never work or it would not be possible to make it work.

https://github.com/fastify/fastify-nextjs/blob/master/test/index.test.js

@mcollina mcollina added the bug Confirmed bug label May 15, 2023
@joshuaavalon
Copy link
Author

My current workaround is just to not register this plugin when using inject.

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

No branches or pull requests

2 participants