Skip to content

Commit c33c59c

Browse files
committed
fix: getDbInstance instead of closeDbInstance
1 parent cdc5d8c commit c33c59c

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

apps/postgres-new/app/db/[id]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function Page({ params }: { params: { id: string } }) {
1717
}
1818

1919
try {
20-
await dbManager.closeDbInstance(databaseId)
20+
await dbManager.getDbInstance(databaseId)
2121
} catch (err) {
2222
router.push('/')
2323
}

apps/postgres-new/components/app-provider.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import { createClient } from '~/utils/supabase/client'
2020

2121
export type AppProps = PropsWithChildren
2222

23+
// Create a singleton DbManager that isn't exposed to double mounting
24+
const dbManager = typeof window !== 'undefined' ? new DbManager() : undefined
25+
2326
export default function AppProvider({ children }: AppProps) {
2427
const [isLoadingUser, setIsLoadingUser] = useState(true)
2528
const [user, setUser] = useState<User>()
@@ -77,10 +80,6 @@ export default function AppProvider({ children }: AppProps) {
7780
setUser(undefined)
7881
}, [supabase])
7982

80-
const dbManager = useMemo(() => {
81-
return typeof window !== 'undefined' ? new DbManager() : undefined
82-
}, [])
83-
8483
const isPreview = process.env.NEXT_PUBLIC_IS_PREVIEW === 'true'
8584
const pgliteVersion = process.env.NEXT_PUBLIC_PGLITE_VERSION
8685
const { value: pgVersion } = useAsyncMemo(async () => {

0 commit comments

Comments
 (0)