Can't use Knex in instrumentation hook
exoRift opened this issue · 4 comments
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/ecstatic-black-2cz5ks
To Reproduce
- Create an instrumentation hook
- 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.
Been having this issue as well!
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
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!
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.