-
-
Notifications
You must be signed in to change notification settings - Fork 662
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
Context storage not available #3944
Labels
Comments
Hi @samducker I can't reproduce it. Can you share a minimal project to reproduce it? |
Ok thank you! I will do soon 🙏🏻. Maybe related to one of my middleware's.
…On Sun, 23 Feb 2025 at 06:34, Yusuke Wada < ***@***.*** > wrote:
Hi @samducker ( https://github.com/samducker )
I can't reproduce it. Can you share a minimal project to reproduce it?
—
Reply to this email directly, view it on GitHub (
#3944 (comment) ) , or unsubscribe
(
https://github.com/notifications/unsubscribe-auth/AF7VYS2N3D6PNVKFLWOUZ6D2RFTYZAVCNFSM6AAAAABXV4NPG2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNZWGY2TENJRHE
).
You are receiving this because you were mentioned. Message ID: <honojs/hono/issues/3944/2676652519
@ github. com>
*yusukebe* left a comment (honojs/hono#3944) (
#3944 (comment) )
Hi @samducker ( https://github.com/samducker )
I can't reproduce it. Can you share a minimal project to reproduce it?
—
Reply to this email directly, view it on GitHub (
#3944 (comment) ) , or unsubscribe
(
https://github.com/notifications/unsubscribe-auth/AF7VYS2N3D6PNVKFLWOUZ6D2RFTYZAVCNFSM6AAAAABXV4NPG2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNZWGY2TENJRHE
).
You are receiving this because you were mentioned. Message ID: <honojs/hono/issues/3944/2676652519
@ github. com>
|
Using hono 4.7.2 and having similar issue This works import { drizzle } from 'drizzle-orm/neon-http'
import { getContext } from 'hono/context-storage'
import type { AppEnv } from '@/shared/app'
export const db = () => {
const c = getContext<AppEnv>()
return drizzle(c.env.DATABASE_URL)
} But this does not import { drizzle } from 'drizzle-orm/neon-http'
import { getContext } from 'hono/context-storage'
import type { AppEnv } from '@/shared/app'
const getDb = () => {
const c = getContext<AppEnv>()
return drizzle(c.env.DATABASE_URL)
}
export const db = getDb() Error Uncaught Error: Context is not available
at null.<anonymous> (index.js:8277:11) in getContext
at null.<anonymous> (index.js:26059:13) in getDb
at null.<anonymous> (index.js:26062:10) Ideally, I want to use something like this: import { drizzle } from 'drizzle-orm/neon-http'
import { getContext } from 'hono/context-storage'
import type { AppEnv } from '@/shared/app'
const getDatabaseUrl = (): string => {
return getContext<AppEnv>().env.DATABASE_URL
}
export const db = drizzle(getDatabaseUrl()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What version of Hono are you using?
4.6.12
What runtime/platform is your app running on? (with version if possible)
Cloudflare Workers
What steps can reproduce the bug?
When implementing https://hono.dev/docs/middleware/builtin/context-storage#context-storage-middleware with https://developers.cloudflare.com/workers/runtime-apis/nodejs/asynclocalstorage/ and the correct flags listed in the docs I get the error
What is the expected behavior?
No response
What do you see instead?
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: