JoelLefkowitz / cached-prisma

A Prisma client abstraction that simplifies caching.
MIT License
68 stars 9 forks source link

Startup error #10

Closed victor-floor closed 6 days ago

victor-floor commented 1 month ago

Bug Report

Fresh install. Prisma 5.10.1 (and client). This error prevents the application from starting.

Description

...\node_modules\@peculiar\asn1-schema\build\cjs\schema.js:17 throw new Error(Cannot get schema for '${target.prototype.constructor.name}' target); ^ source-map-support.js:722 Error: Cannot get schema for 'Array' target at AsnSchemaStorage.get (C:\dev\userprofile-microservice\node_modules\@peculiar\asn1-schema\build\cjs\schema.js:17:19) at Function.toASN (C:\dev\userprofile-microservice\node_modules\@peculiar\asn1-schema\build\cjs\serializer.js:24:48) at Function.toAsnItem (C:\dev\userprofile-microservice\node_modules\@peculiar\asn1-schema\build\cjs\serializer.js:152:33) at Function.toASN (C:\dev\userprofile-microservice\node_modules\@peculiar\asn1-schema\build\cjs\serializer.js:52:48) at Function.serialize (C:\dev\userprofile-microservice\node_modules\@peculiar\asn1-schema\build\cjs\serializer.js:14:21) at Function.serialize (C:\dev\userprofile-microservice\node_modules\@peculiar\asn1-schema\build\cjs\convert.js:10:43) at X509Certificate.onInit (C:\dev\userprofile-microservice\node_modules\@peculiar\x509\build\x509.cjs.js:2322:42) at new AsnData (C:\dev\userprofile-microservice\node_modules\@peculiar\x509\build\x509.cjs.js:449:18) at new PemData (C:\dev\userprofile-microservice\node_modules\@peculiar\x509\build\x509.cjs.js:1251:13) at new X509Certificate (C:\dev\userprofile-microservice\node_modules\@peculiar\x509\build\x509.cjs.js:2313:13)

...

Minimal Reproduction

...

Stack trace

...

Environment

...
JoelLefkowitz commented 1 month ago

@victor-floor thanks for raising this, could you share your package.json please?

victor-floor commented 1 month ago

@victor-floor thanks for raising this, could you share your package.json please?

This is the package.json before trying to add cached-prisma. While adding it, I did try updating prisma to the same version used by cached-prisma with the same error.

{
  "name": "api",
  "description": "Serving API requests related to personal properties of the user",
  "version": "0.0.1",
  "main": "./dist/server.js",
  "license": "UNLICENSED",
  "engines": {
    "node": "20.x"
  },
  "scripts": {
    ...
  },
  "lint-staged": {
    "*.ts": "eslint --fix",
    "*": "prettier --config .prettierrc --ignore-unknown --write"
  },
  "dependencies": {
    "@alch/alchemy-web3": "^1.4.7",
    "@aws-sdk/client-s3": "^3.596.0",
    "@aws-sdk/credential-provider-node": "^3.395.0",
    "@aws-sdk/s3-request-presigner": "^3.596.0",
    "@blowfishxyz/api-client": "^0.1.17",
    "@coinbase/cbpay-js": "^1.10.0",
    "@interop/base58-universal": "^1.0.0",
    "@jup-ag/api": "^6.0.26",
    "@jup-ag/referral-sdk": "^0.1.7",
    "@koa/router": "^13.1.0",
    "@magic-sdk/admin": "^2.0.1",
    "@opensearch-project/opensearch": "^2.3.1",
    "@prisma/client": "^5.6.0",
    "@prisma/extension-read-replicas": "^0.4.0",
    "@sentry/node": "^7.106.0",
    "@sentry/utils": "^7.61.0",
    "@solana/spl-token": "^0.4.8",
    "@solana/web3.js": "^1.95.2",
    "@types/node-fetch": "^2.6.4",
    "@types/qs": "^6.9.7",
    "alchemy-sdk": "^3.1.2",
    "appattest-checker-node": "^1.0.2",
    "axios": "^1.7.4",
    "axios-mock-adapter": "^1.22.0",
    "axios-retry": "^4.5.0",
    "bs58": "^5.0.0",
    "cachios": "^4.0.0",
    "cls-rtracer": "^2.6.3",
    "dayjs": "^1.11.4",
    "device-check": "^2.3.1",
    "dotenv": "^16.3.1",
    "elastic-builder": "^2.21.0",
    "ethers": "^6.6.1",
    "fetch-retry": "^5.0.6",
    "googleapis": "^144.0.0",
    "helius-sdk": "^1.3.4",
    "http-graceful-shutdown": "^3.1.8",
    "isomorphic-fetch": "^3.0.0",
    "jimp": "^0.22.8",
    "joi": "^17.9.2",
    "jsonwebtoken": "^9.0.2",
    "koa": "^2.15.3",
    "koa-bodyparser": "^4.4.1",
    "koa-compress": "^5.1.1",
    "koa2-swagger-ui": "^5.10.0",
    "lodash": "^4.17.21",
    "qs": "^6.11.2",
    "throng": "^5.0.0",
    "tslib": "^2.6.0",
    "tsoa": "^6.4.0",
    "tweetnacl": "^1.0.3",
    "twitter-api-v2": "^1.14.2",
    "typescript": "5.5.4",
    "winston": "^3.9.0",
    "zlib": "^1.0.5"
  },
  "devDependencies": {
    "@faker-js/faker": "^8.4.1",
    "@istanbuljs/nyc-config-typescript": "^1.0.2",
    "@types/bull": "3.15.8",
    "@types/chai": "^4.3.5",
    "@types/chai-as-promised": "^7.1.5",
    "@types/isomorphic-fetch": "^0.0.36",
    "@types/jsonwebtoken": "^9.0.7",
    "@types/koa": "^2.15.0",
    "@types/koa-bodyparser": "^4.3.7",
    "@types/koa-compress": "^4.0.3",
    "@types/koa__router": "^12.0.4",
    "@types/lodash": "^4.14.195",
    "@types/mocha": "^10.0.1",
    "@types/sinon": "^10.0.15",
    "@types/supertest": "^2.0.12",
    "@types/throng": "^5.0.4",
    "@types/uuid": "^9.0.2",
    "@typescript-eslint/eslint-plugin": "^5.60.1",
    "@typescript-eslint/parser": "^5.60.1",
    "chai": "^4.3.7",
    "chai-as-promised": "^7.1.1",
    "chai-exclude": "^2.1.0",
    "concurrently": "^8.2.0",
    "doctoc": "^2.2.1",
    "eslint": "^8.43.0",
    "husky": "^8.0.3",
    "lint-staged": "^13.2.2",
    "mocha": "^10.2.0",
    "nock": "^13.3.1",
    "node-gyp": "^10.0.1",
    "nodemon": "^2.0.22",
    "nyc": "^15.1.0",
    "prettier": "^3.0.0",
    "prisma": "^5.6.0",
    "sinon": "^15.2.0",
    "supertest": "^6.3.3",
    "ts-node": "10.9.2",
    "tsc-alias": "^1.8.6",
    "tsconfig-paths": "^4.2.0"
  },
  "prisma": {
    "schema": "./src/prisma/schema.prisma"
  }
}
JoelLefkowitz commented 1 month ago

@victor-floor since the error is occurring in ...\node_modules@peculiar\asn1-schema\build\cjs\schema.js:17 how do you know it's due to cached-prisma. Is there error occurring during the install itself or do you have an main script file you can share that shows where cached-prisma is used?

victor-floor commented 1 month ago

@victor-floor since the error is occurring in ...\node_modules@peculiar\asn1-schema\build\cjs\schema.js:17 how do you know it's due to cached-prisma. Is there error occurring during the install itself or do you have an main script file you can share that shows where cached-prisma is used?

I don't know if it's cached-prisma or a dependency of it, but I've been using prisma for over a year without issues and it works fine if I do not include cached-prisma. There is no error during the install. It's a runtime error. I've since removed the code that uses cached-prisma, but it was identical to your initialization code.

JoelLefkowitz commented 1 month ago

Was it this snippet:

import { Prisma } from "cached-prisma";

const client = new Prisma().client;

I cannot reproduce the error myself, looks like it is occurring in @peculiar\asn1-schema which isn't a dependency in the and doesn't appear in the yarn.lock file.

Are you calling AsnConvert.serialize() somewhere in your code to trigger this error maybe?

JoelLefkowitz commented 6 days ago

Hey @victor-floor since I can't reproduce the issue I'm going to close this thread. If the issue persists and you have some steps for reproduction please open another issue :)