diff --git a/packages/google-cloud-serverless/test/gcpfunction/cloud_event.test.ts b/packages/google-cloud-serverless/test/gcpfunction/cloud_event.test.ts index 95323881828d..8bbc926643f7 100644 --- a/packages/google-cloud-serverless/test/gcpfunction/cloud_event.test.ts +++ b/packages/google-cloud-serverless/test/gcpfunction/cloud_event.test.ts @@ -1,4 +1,3 @@ -import * as domain from 'domain'; import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core'; import { wrapCloudEventFunction } from '../../src/gcpfunction/cloud_events'; @@ -44,21 +43,21 @@ describe('wrapCloudEventFunction', () => { function handleCloudEvent(fn: CloudEventFunctionWithCallback): Promise { return new Promise((resolve, reject) => { - // eslint-disable-next-line deprecation/deprecation - const d = domain.create(); const context = { type: 'event.type', }; - d.on('error', reject); - d.run(() => - process.nextTick(fn, context, (err: any, result: any) => { + + try { + fn(context, (err: any, result: any) => { if (err != null || err != undefined) { reject(err); } else { resolve(result); } - }), - ); + }); + } catch (error) { + reject(error); + } }); } diff --git a/packages/google-cloud-serverless/test/gcpfunction/events.test.ts b/packages/google-cloud-serverless/test/gcpfunction/events.test.ts index aa449f5407c9..aad3d5ec1645 100644 --- a/packages/google-cloud-serverless/test/gcpfunction/events.test.ts +++ b/packages/google-cloud-serverless/test/gcpfunction/events.test.ts @@ -1,4 +1,3 @@ -import * as domain from 'domain'; import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core'; import type { Event } from '@sentry/core'; @@ -45,22 +44,18 @@ describe('wrapEventFunction', () => { function handleEvent(fn: EventFunctionWithCallback): Promise { return new Promise((resolve, reject) => { - // eslint-disable-next-line deprecation/deprecation - const d = domain.create(); const context = { eventType: 'event.type', resource: 'some.resource', }; - d.on('error', reject); - d.run(() => - process.nextTick(fn, {}, context, (err: any, result: any) => { - if (err != null || err != undefined) { - reject(err); - } else { - resolve(result); - } - }), - ); + + fn({}, context, (err: any, result: any) => { + if (err != null || err != undefined) { + reject(err); + } else { + resolve(result); + } + }); }); } diff --git a/packages/google-cloud-serverless/test/gcpfunction/http.test.ts b/packages/google-cloud-serverless/test/gcpfunction/http.test.ts index 08d53df50b31..7f456237ad9c 100644 --- a/packages/google-cloud-serverless/test/gcpfunction/http.test.ts +++ b/packages/google-cloud-serverless/test/gcpfunction/http.test.ts @@ -1,5 +1,3 @@ -import * as domain from 'domain'; - import type { Integration } from '@sentry/core'; import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core'; @@ -58,8 +56,6 @@ describe('GCPFunction', () => { headers = { ...headers, ...trace_headers }; } return new Promise((resolve, _reject) => { - // eslint-disable-next-line deprecation/deprecation - const d = domain.create(); const req = { method: 'POST', url: '/path?q=query', @@ -67,8 +63,12 @@ describe('GCPFunction', () => { body: { foo: 'bar' }, } as Request; const res = { end: resolve } as Response; - d.on('error', () => res.end()); - d.run(() => process.nextTick(fn, req, res)); + + try { + fn(req, res); + } catch (error) { + res.end(); + } }); }