Skip to content
← Back to activity

Immutable solution version

0.4.5 Error - Cannot read properties of undefined (reading 'subtle')

Version 2

Complete solution

Shows how to fix 0.4.5 Error - Cannot read properties of undefined (reading 'subtle'). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Follow-up issue on the same thread - 0.4.4's new default export broke named imports under esbuild/Cloudflare - fixed in 0.4.10 (reporter confirmed).

Steps

  1. Issue neondatabase/serverless#19 (closed, 7 comments): ## Steps to reproduce

npx nuxi init [project-name] yarn add drizzle-orm @neondatabase/serverless yarn add -D drizzle-kit

  1. `

import {neonConfig, Pool} from '@neondatabase/serverless'; import {drizzle, NeonDatabase} from 'drizzle-orm/neon-serverless'; import * as schema from '~/server/drizzle/schema';

  1. // if we're running locally

if (!process.env.VERCEL_ENV) { // Set the WebSocket proxy to work with the local instance neonConfig.wsProxy = (host) => ${host}:5433/v1 // Disable all authentication and encryption neonConfig.useSecureWebSocket = false neonConfi

  1. [jawj (maintainer)]: The driver needs SubtleCrypto. Options: drop ?sslmode=require when connecting to a local DB in dev; use Node 20 (global webcrypto); Node 18 with --experimental-global-webcrypto; or polyfill before import: import crypto from 'crypto'; globalThis.crypto = crypto; then dynamically import the driver. Follow-up issue on the same thread - 0.4.4's new default export broke named imports under esbuild/Cloudflare - fixed in 0.4.10 (reporter confirmed).

When to use

You are seeing this: [jawj (maintainer)]: The driver needs SubtleCrypto. Use this skill when you run into "0.4.5 Error - Cannot read properties of undefined (reading 'subtle')".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

Versions mentioned in the source: - 0.4.4, 0.4.10. If you are on something much newer or older, the details may have shifted.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Asked in gh:neondatabase/serverless#19 (https://github.com/neondatabase/serverless/issues/19): 0.4.5 Error - Cannot read properties of undefined (reading 'subtle'). The issue report: Issue neondatabase/serverless#19 (closed, 7 comments): ## Steps to reproduce npx nuxi init [project-name] yarn add drizzle-orm @neondatabase/serverless yarn add -D drizzle-kit

db.ts

import {neonConfig, Pool} from '@neondatabase/serverless';
import {drizzle, NeonDatabase} from 'drizzle-orm/neon-serverless';
import * as schema from '~/server/drizzle/schema';

// if we're running locally
if (!process.env.VERCEL_ENV) {
  // Set the WebSocket proxy to work with the local instance
  neonConfig.wsProxy = (host) => `${host}:5433/v1`
  // Disable all authentication and encryption
  neonConfig.useSecureWebSocket = false
  neonConfi The verified answer: [jawj (maintainer)]: The driver needs SubtleCrypto. Options: drop `?sslmode=require` when connecting to a local DB in dev; use Node 20 (global webcrypto); Node 18 with `--experimental-global-webcrypto`; or polyfill before import: `import crypto from 'crypto'; globalThis.crypto = crypto;` then dynamically import the driver. Follow-up issue on the same thread  -  0.4.4's new default export broke named imports under esbuild/Cloudflare  -  fixed in 0.4.10 (reporter confirmed).

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_FZJTcN5EktLEIWynQYxndQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">0.4.5 Error - Cannot read properties of undefined (reading &#39;subtle&#39;) <span>— Vectle</span></a>

0.4.5 Error - Cannot read properties of undefined (reading 'subtle') | Vectle