Skip to content

Commit

Permalink
Remove Middleware warning message. (#37973)
Browse files Browse the repository at this point in the history
* Remove Middleware warning message.

* lint-fix

Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
leerob and ijjk committed Jun 24, 2022
1 parent e28d03c commit 07a6d4a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 41 deletions.
7 changes: 0 additions & 7 deletions packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ import {
copyTracedFiles,
isReservedPage,
isServerComponentPage,
isMiddlewareFile,
} from './utils'
import getBaseWebpackConfig from './webpack-config'
import { PagesManifest } from './webpack/plugins/pages-manifest-plugin'
Expand Down Expand Up @@ -431,12 +430,6 @@ export default async function build(
const hasCustomErrorPage =
mappedPages['/_error'].startsWith(PAGES_DIR_ALIAS)

if (Object.keys(mappedRootPaths || {}).some(isMiddlewareFile)) {
Log.warn(
`using beta Middleware (not covered by semver) - https://nextjs.org/docs/messages/beta-middleware`
)
}

if (hasPublicDir) {
const hasPublicUnderScoreNextDir = await fileExists(
path.join(publicDir, '_next')
Expand Down
17 changes: 2 additions & 15 deletions packages/next/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import './node-polyfill-fetch'
import './node-polyfill-web-streams'

import type { Route } from './router'
import {
CacheFs,
DecodeError,
execOnce,
PageNotFoundError,
} from '../shared/lib/utils'
import { CacheFs, DecodeError, PageNotFoundError } from '../shared/lib/utils'
import type { MiddlewareManifest } from '../build/webpack/plugins/middleware-plugin'
import type RenderResult from './render-result'
import type { FetchEventResult } from './web/types'
Expand Down Expand Up @@ -109,12 +104,6 @@ export interface NodeRequestHandler {
): Promise<void>
}

const middlewareBetaWarning = execOnce(() => {
Log.warn(
`using beta Middleware (not covered by semver) - https://nextjs.org/docs/messages/beta-middleware`
)
})

export default class NextNodeServer extends BaseServer {
private imageResponseCache?: ResponseCache

Expand Down Expand Up @@ -1162,9 +1151,7 @@ export default class NextNodeServer extends BaseServer {
parsed: UrlWithParsedQuery
onWarning?: (warning: Error) => void
}) {
middlewareBetaWarning()

// middleware is skipped for on-demand revalidate requests
// Middleware is skipped for on-demand revalidate requests
if (
checkIsManualRevalidate(params.request, this.renderOpts.previewProps)
.isManualRevalidate
Expand Down
20 changes: 1 addition & 19 deletions test/e2e/middleware-general/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import fs from 'fs-extra'
import { join } from 'path'
import webdriver from 'next-webdriver'
import { NextInstance } from 'test/lib/next-modes/base'
import { check, fetchViaHTTP, renderViaHTTP, waitFor } from 'next-test-utils'
import { check, fetchViaHTTP, waitFor } from 'next-test-utils'
import { createNext, FileRef } from 'e2e-utils'
import escapeStringRegexp from 'escape-string-regexp'

const middlewareWarning = 'using beta Middleware (not covered by semver)'
const urlsError = 'Please use only absolute URLs'

describe('Middleware Runtime', () => {
Expand Down Expand Up @@ -76,14 +74,6 @@ describe('Middleware Runtime', () => {

function runTests({ i18n }: { i18n?: boolean }) {
if ((global as any).isNextDev) {
it('should have showed warning for middleware usage', async () => {
await renderViaHTTP(next.url, '/')
await check(
() => next.cliOutput,
new RegExp(escapeStringRegexp(middlewareWarning))
)
})

it('refreshes the page when middleware changes ', async () => {
const browser = await webdriver(next.url, `/about`)
await browser.eval('window.didrefresh = "hello"')
Expand Down Expand Up @@ -128,14 +118,6 @@ describe('Middleware Runtime', () => {
})
})

it('should have middleware warning during build', () => {
expect(next.cliOutput).toContain(middlewareWarning)
})

it('should have middleware warning during start', () => {
expect(next.cliOutput).toContain(middlewareWarning)
})

it('should have correct files in manifest', async () => {
const manifest = await fs.readJSON(
join(next.testDir, '.next/server/middleware-manifest.json')
Expand Down

0 comments on commit 07a6d4a

Please sign in to comment.