Skip to content

Commit b6a4a4a

Browse files
author
Luca Forstner
authored
fix(node/v8): Add compatibility layer for Prisma v5 (#15210)
1 parent 3673689 commit b6a4a4a

File tree

23 files changed

+342
-19
lines changed

23 files changed

+342
-19
lines changed

dev-packages/node-integration-tests/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
"build:types": "tsc -p tsconfig.types.json",
1717
"clean": "rimraf -g **/node_modules && run-p clean:script",
1818
"clean:script": "node scripts/clean.js",
19-
"prisma:init": "(cd suites/tracing/prisma-orm && ts-node ./setup.ts)",
19+
"prisma-v5:init": "cd suites/tracing/prisma-orm-v5 && ts-node ./setup.ts",
20+
"prisma-v6:init": "cd suites/tracing/prisma-orm-v6 && ts-node ./setup.ts",
2021
"lint": "eslint . --format stylish",
2122
"fix": "eslint . --format stylish --fix",
2223
"type-check": "tsc",
23-
"pretest": "run-s --silent prisma:init",
24+
"pretest": "run-s --silent prisma-v5:init prisma-v6:init",
2425
"test": "jest --config ./jest.config.js",
2526
"test:watch": "yarn test --watch"
2627
},
@@ -30,7 +31,6 @@
3031
"@nestjs/common": "10.4.6",
3132
"@nestjs/core": "10.4.6",
3233
"@nestjs/platform-express": "10.4.6",
33-
"@prisma/client": "5.22.0",
3434
"@sentry/aws-serverless": "8.53.0",
3535
"@sentry/core": "8.53.0",
3636
"@sentry/node": "8.53.0",

dev-packages/node-integration-tests/suites/tracing/prisma-orm/docker-compose.yml renamed to dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
db:
55
image: postgres:13
66
restart: always
7-
container_name: integration-tests-prisma
7+
container_name: integration-tests-prisma-v5
88
ports:
99
- '5433:5432'
1010
environment:

dev-packages/node-integration-tests/suites/tracing/prisma-orm/package.json renamed to dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
"version": "1.0.0",
44
"description": "",
55
"main": "index.js",
6-
"engines": {
7-
"node": ">=16"
8-
},
96
"scripts": {
107
"db-up": "docker compose up -d",
118
"generate": "prisma generate",
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const Sentry = require('@sentry/node');
2+
const { loggingTransport } = require('@sentry-internal/node-integration-tests');
3+
4+
Sentry.init({
5+
dsn: 'https://[email protected]/1337',
6+
release: '1.0',
7+
tracesSampleRate: 1.0,
8+
transport: loggingTransport,
9+
integrations: [Sentry.prismaIntegration()],
10+
});
11+
12+
const { randomBytes } = require('crypto');
13+
const { PrismaClient } = require('@prisma/client');
14+
15+
// Stop the process from exiting before the transaction is sent
16+
setInterval(() => {}, 1000);
17+
18+
async function run() {
19+
const client = new PrismaClient();
20+
21+
await Sentry.startSpanManual(
22+
{
23+
name: 'Test Transaction',
24+
op: 'transaction',
25+
},
26+
async span => {
27+
await client.user.create({
28+
data: {
29+
name: 'Tilda',
30+
email: `tilda_${randomBytes(4).toString('hex')}@sentry.io`,
31+
},
32+
});
33+
34+
await client.user.findMany();
35+
36+
await client.user.deleteMany({
37+
where: {
38+
email: {
39+
contains: 'sentry.io',
40+
},
41+
},
42+
});
43+
44+
setTimeout(async () => {
45+
span.end();
46+
await client.$disconnect();
47+
}, 500);
48+
},
49+
);
50+
}
51+
52+
run();

0 commit comments

Comments
 (0)