Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unneeded waiting in otel tests #47431

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/next/src/server/dev/next-dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ import { logAppDirError } from './log-app-dir-error'
import { createClientRouterFilter } from '../../lib/create-client-router-filter'
import { IncrementalCache } from '../lib/incremental-cache'
import LRUCache from 'next/dist/compiled/lru-cache'
import { NextUrlWithParsedQuery } from '../request-meta'

// Load ReactDevOverlay only when needed
let ReactDevOverlayImpl: FunctionComponent
Expand Down Expand Up @@ -1156,6 +1157,15 @@ export default class DevServer extends Server {
}
}

public async handleRequest(
req: BaseNextRequest,
res: BaseNextResponse,
parsedUrl?: NextUrlWithParsedQuery
): Promise<void> {
await this.devReady
return await super.handleRequest(req, res, parsedUrl)
}

async run(
req: NodeNextRequest,
res: NodeNextResponse,
Expand Down
1 change: 0 additions & 1 deletion test/e2e/opentelemetry/app/app/[param]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export default async function Layout({
}: {
children: React.ReactNode
}) {
await new Promise((resolve) => setTimeout(resolve, 5000))
return (
<html>
<body>{children}</body>
Expand Down
18 changes: 0 additions & 18 deletions test/e2e/opentelemetry/opentelemetry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,6 @@ createNextDescribe(
.map((line) => JSON.parse(line))
}

/** There were issues where OTEL might not be initialized for first few requests (this is a bug).
* It made our tests, flaky. This should make tests deterministic.
*/
const waitForOtelToInitialize = async () => {
await check(
async () =>
await next
.readFile(traceFile)
.then(() => 'ok')
.catch(() => 'err'),
'ok'
)
}

const waitForRootSpan = async (numberOfRootTraces: number) => {
await check(async () => {
const spans = await getTraces()
Expand Down Expand Up @@ -72,10 +58,6 @@ createNextDescribe(
await next.patchFile(traceFile, '')
}

beforeAll(async () => {
await waitForOtelToInitialize()
})

afterEach(async () => {
await cleanTraces()
})
Expand Down