Skip to content

Commit 4b6f920

Browse files
committed
actually introduce random numbers
1 parent 58315e4 commit 4b6f920

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

packages/remix/src/utils/serverAdapters/express.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { getCurrentHub } from '@sentry/hub';
2+
import { hasTracingEnabled } from '@sentry/tracing';
13
import { extractRequestData, loadModule } from '@sentry/utils';
24
import * as domain from 'domain';
35

@@ -17,8 +19,6 @@ import {
1719
ReactRouterDomPkg,
1820
ServerBuild,
1921
} from '../types';
20-
import { getCurrentHub } from '@sentry/hub';
21-
import { hasTracingEnabled } from '@sentry/tracing';
2222

2323
function wrapExpressRequestHandler(
2424
origRequestHandler: ExpressRequestHandler,
@@ -67,7 +67,9 @@ function wrapExpressRequestHandler(
6767
*/
6868
export function wrapExpressCreateRequestHandler(
6969
origCreateRequestHandler: ExpressCreateRequestHandler,
70+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7071
): (options: any) => ExpressRequestHandler {
72+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7173
return function (this: unknown, options: any): ExpressRequestHandler {
7274
const newBuild = instrumentBuild((options as ExpressCreateRequestHandlerOptions).build);
7375
const requestHandler = origCreateRequestHandler.call(this, { ...options, build: newBuild });

packages/remix/test/integration/app/routes/scope-bleed/$id.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import * as Sentry from '@sentry/remix';
44

55
export const loader: LoaderFunction = async ({ params: { id } }) => {
66
// Set delay to simulate requests at the same time
7-
await new Promise(resolve => setTimeout(resolve, 5000 - (parseInt(id || '', 10) * 1000 - 1000 - 14)));
7+
const randomNum = Math.floor(Math.random() * 15) + 1;
8+
await new Promise(resolve => setTimeout(resolve, 4000 - (parseInt(id || '', 10) * 1000 - randomNum)));
89
Sentry.setTag(`tag${id}`, id);
910
return json({ test: 'test' });
1011
};

packages/remix/test/integration/test/server/loader.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', ada
145145
const url = `${baseURL}/scope-bleed/${id}`;
146146
// Send requests with 1 sec delays, but they should all resolve at the same time
147147
// See packages/remix/test/integration/app/routes/scope-bleed/$id.tsx
148-
// for server-side set up. Add 13 for a bit of randomness.
149-
await new Promise(resolve => setTimeout(resolve, id * 1000 - 1000 + 13));
148+
// for server-side set up.
149+
const randomNum = Math.floor(Math.random() * 15) + 1;
150+
await new Promise(resolve => setTimeout(resolve, id * 1000 - 1000 + randomNum));
150151
const envelope = await getEnvelopeRequest(url);
151152
const transaction = envelope[2];
152153

0 commit comments

Comments
 (0)