H
Hono•4w ago
JustUseFirefox

RPC type error - Unable to interop

Repro repo: https://codeberg.org/Dreamboat9222/ioMonorepo-Edgedb-Hono-Svelte In a monorepo, I have hono api in one package, and the ui (Svelte) in another and use EdgeDB as the database. It was working a couple of days ago, but I lost all intellisense abilities for 4 days so I was basically coding inside notepad 😂 (The issue is now fixed), but since then this stopped working. I also posted on the edgedb server, but I didn't receive any reply yet. Posting here in case someone have an idea on what is going wrong. Inside hono if I remove the database from context the error disappear:
app.use(async (c, next) => {
c.set('dbClient', createClient());
c.set('e', e);
await next();
});
app.use(async (c, next) => {
c.set('dbClient', createClient());
c.set('e', e);
await next();
});
In svelte I import this to make API queries:
import { type AppRouter } from "@repo/api-hono"
import { hc } from 'hono/client'

export const hono = hc<AppRouter>(API_ENDPOINT, {
init: {
credentials: 'include'
}
});
import { type AppRouter } from "@repo/api-hono"
import { hc } from 'hono/client'

export const hono = hc<AppRouter>(API_ENDPOINT, {
init: {
credentials: 'include'
}
});
But for some reason, when I try to load the UI, it throws Unable to interop export * from "edgedb/dist/reflection/index.js" in ...Monorepo/dbschema/edgeql-js/reflection.mts, this may lose module exports. Please export "edgedb/dist/reflection/index.js" as ESM or use named exports instead, e.g. export { A, B } from "edgedb/dist/reflection/index.js" Removing import { type AppRouter } from "@repo/api-hono" and the type next to hc removes the error, but then I lose all types for my API calls. Edgedb types are generated with bunx @edgedb/generate edgeql-js --target esm (I tried mts too, same error) Inside the browser, the following error appear: TypeError: $.StrictMap is not a constructor` - I removed all node_modules folders and reinstalled the deps - I removed dbschema/edgeql-js and regenerated the types - I double-checked tsconfig files but didn't spot anything, but I'm no specialist. Any idea please ? 😰
Codeberg.org
ioMonorepo-Edgedb-Hono-Svelte
Reproduction repo
2 Replies
JustUseFirefox
JustUseFirefox•4w ago
EdgeDB dev confirmed that, for some reason now, hono exports server-only code related to the database and that code gets imported client-side with RPC. Yup, Hono's side of things. I've updated the repo with a simpler version that doesnt rely on @repo/edgedb and multiple imports but the error persist no matter what. Everything points to Hono, as soon as import { type AppRouter } from "@repo/api-hono" is present in Svelte ui, the error appears. But this is kind of required to make use of RPC 😂 Someone over at edgedb suggested removing the context and calling the database directly inside a route, but the issue persist. I think it's either how edge e returns type, or how hono infer types for RPC
const routes = app
.post(
'/',
async (c) => {

// Calling this here: fine
const dbClient = createClient();
// Calling this here: error !
const res = await e.select(e.Post).run(dbClient);




const json = await c.req.parseBody();

return c.json({
type: 'authn',
status: 'valid',
});
}
)
const routes = app
.post(
'/',
async (c) => {

// Calling this here: fine
const dbClient = createClient();
// Calling this here: error !
const res = await e.select(e.Post).run(dbClient);




const json = await c.req.parseBody();

return c.json({
type: 'authn',
status: 'valid',
});
}
)
Git link updated
JustUseFirefox
JustUseFirefox•4w ago
GitHub
RPC tries to import server-side database code into the client and m...
What version of Hono are you using? 4.6.3 What runtime/platform is your app running on? Bun 1.1.29 What steps can reproduce the bug? Use EdgeDB Use Hono RPC and export routes types What is the expe...
Want results from more Discord servers?
Add your server