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

Can't use Knex in instrumentation hook #65863

Closed
exoRift opened this issue May 16, 2024 · 3 comments
Closed

Can't use Knex in instrumentation hook #65863

exoRift opened this issue May 16, 2024 · 3 comments
Labels
bug Issue was opened via the bug report template. Instrumentation Related to Next.js Instrumentation. Pages Router Related to Pages Router. Runtime Related to Node.js or Edge Runtime with Next.js. SWC Related to minification/transpilation in Next.js.

Comments

@exoRift
Copy link

exoRift commented May 16, 2024

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/ecstatic-black-2cz5ks

To Reproduce

  1. Create an instrumentation hook
  2. Imports Knex and attempt to run a query

Current vs. Expected behavior

I expect it to work, instead I run into an import error

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.5.0: Wed May  1 20:19:05 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8112
  Available memory (MB): 24576
  Available CPU cores: 8
Binaries:
  Node: 18.19.0
  npm: 10.2.3
  Yarn: N/A
  pnpm: 8.15.1
Relevant Packages:
  next: 14.2.3 // Latest available version is detected (14.2.3).
  eslint-config-next: 14.1.1
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.4.5
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Instrumentation, Pages Router, Runtime, SWC

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local)

Additional context

This is the same issue as #52091

However, the difference is that I'm using Pages router with instrumentation. The issue I linked above suggests to use serverComponentsExternalPackages. However, this turns on App Router features that has consequences that cause errors.

According to the Next docs, there's an option serverExternalPackages. However, it seems this option is no longer in the config? There's no intellisense for it and manually putting it in the config causes an error.

I've done this setup before in an earlier version of Next and downgrading isn't a possibility for me right now.

@exoRift exoRift added the bug Issue was opened via the bug report template. label May 16, 2024
@github-actions github-actions bot added Instrumentation Related to Next.js Instrumentation. Pages Router Related to Pages Router. Runtime Related to Node.js or Edge Runtime with Next.js. SWC Related to minification/transpilation in Next.js. labels May 16, 2024
@noehoro
Copy link

noehoro commented May 21, 2024

Been having this issue as well!

@exoRift
Copy link
Author

exoRift commented May 22, 2024

It seems the new property does the same thing. Instead what my issue was was that I was importing React hooks into a file used in instrumentation. Thus, I split that file into two separate files and it's now working

@exoRift exoRift closed this as completed May 22, 2024
@noehoro
Copy link

noehoro commented May 22, 2024

It seems the new property does the same thing. Instead what my issue was was that I was importing React hooks into a file used in instrumentation. Thus, I split that file into two separate files and it's now working

Good to know! I will ensure to do the same thing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Instrumentation Related to Next.js Instrumentation. Pages Router Related to Pages Router. Runtime Related to Node.js or Edge Runtime with Next.js. SWC Related to minification/transpilation in Next.js.
Projects
None yet
Development

No branches or pull requests

2 participants