Unverified Commit 93bb2799 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Apply fixes for onBuildComplete and route module (#88831)

This applies fixes for outputs in `onBuildComplete` with various slight
differences from expected values. This also applies some fixes in the
route-module interface to ensure we install the process handlers for PPR
since currently that was done in `next-server` which we want to get rid
of and there was an edge case with query parsing logic in the
route-module.

Our E2E tests were run against this here to validate
https://github.com/vercel/next.js/actions/runs/21324578779 and failures
are matching existing failures on canary.

x-ref: https://github.com/nextjs/adapter-vercel/pull/11
x-ref: https://github.com/vercel/vercel/pull/14574

---------
Co-authored-by: 's avatarvercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
parent f4c2d546
...@@ -90,6 +90,33 @@ jobs: ...@@ -90,6 +90,33 @@ jobs:
runs_on_labels: '["ubuntu-latest"]' runs_on_labels: '["ubuntu-latest"]'
overrideProxyAddress: ${{ inputs.overrideProxyAddress || '' }} overrideProxyAddress: ${{ inputs.overrideProxyAddress || '' }}
test-deploy-adapter:
name: Run Deploy Adapter Tests
needs: setup
uses: ./.github/workflows/build_reusable.yml
secrets: inherit
strategy:
fail-fast: false
matrix:
group: [1/1]
with:
afterBuild: |
npm i -g vercel@latest && \
NEXT_E2E_TEST_TIMEOUT=240000 \
NEXT_TEST_MODE=deploy \
IS_WEBPACK_TEST=1 \
NEXT_ENABLE_ADAPTER=1 \
NEXT_EXTERNAL_TESTS_FILTERS="test/deploy-tests-manifest.json" \
NEXT_TEST_VERSION="${{ github.event.inputs.nextVersion || needs.setup.outputs.next-version || 'canary' }}" \
VERCEL_CLI_VERSION="${{ github.event.inputs.vercelCliVersion || 'vercel@latest' }}" \
node run-tests.js --timings -g ${{ matrix.group }} -c 2 test/e2e/app-dir/segment-cache/client-params/client-params.test.ts test/e2e/app-dir/app-static/app-static.test.ts test/e2e/app-dir/cache-components/cache-components.test.ts test/e2e/app-dir/app/index.test.ts test/e2e/app-dir/app-edge/app-edge.test.ts test/e2e/edge-pages-support/index.test.ts test/e2e/prerender.test.ts test/e2e/middleware-general/test/index.test.ts test/e2e/middleware-rewrites/test/index.test.ts test/e2e/app-dir/actions/app-action-node-middleware.test.ts
skipNativeBuild: 'yes'
skipNativeInstall: 'no'
stepName: 'test-deploy-adapter-${{ matrix.group }}'
timeout_minutes: 180
runs_on_labels: '["ubuntu-latest"]'
overrideProxyAddress: ${{ inputs.overrideProxyAddress || '' }}
report-test-results-to-datadog: report-test-results-to-datadog:
needs: test-deploy needs: test-deploy
if: ${{ always() }} if: ${{ always() }}
......
...@@ -407,7 +407,7 @@ export async function handler( ...@@ -407,7 +407,7 @@ export async function handler(
// when fixing this to correct logic it causes hydration issue since we set // when fixing this to correct logic it causes hydration issue since we set
// serveStreamingMetadata to true during export // serveStreamingMetadata to true during export
const serveStreamingMetadata = const serveStreamingMetadata =
isHtmlBot && isRoutePPREnabled botType && isRoutePPREnabled
? false ? false
: !userAgent : !userAgent
? true ? true
...@@ -417,9 +417,10 @@ export async function handler( ...@@ -417,9 +417,10 @@ export async function handler(
(prerenderInfo || (prerenderInfo ||
isPrerendered || isPrerendered ||
prerenderManifest.routes[normalizedSrcPage]) && prerenderManifest.routes[normalizedSrcPage]) &&
// If this is a html bot request and PPR is enabled, then we don't want // If this is a bot request and PPR is enabled, then we don't want
// to serve a static response. // to serve a static response. This applies to both DOM bots (like Googlebot)
!(isHtmlBot && isRoutePPREnabled) // and HTML-limited bots.
!(botType && isRoutePPREnabled)
) )
// When a page supports cacheComponents, we can support RDC for Navigations // When a page supports cacheComponents, we can support RDC for Navigations
...@@ -449,8 +450,9 @@ export async function handler( ...@@ -449,8 +450,9 @@ export async function handler(
: // Otherwise, we can support dynamic responses if it's a dynamic RSC request. : // Otherwise, we can support dynamic responses if it's a dynamic RSC request.
isDynamicRSCRequest) isDynamicRSCRequest)
// When html bots request PPR page, perform the full dynamic rendering. // When bots request PPR page, perform the full dynamic rendering.
const shouldWaitOnAllReady = isHtmlBot && isRoutePPREnabled // This applies to both DOM bots (like Googlebot) and HTML-limited bots.
const shouldWaitOnAllReady = Boolean(botType) && isRoutePPREnabled
let ssgCacheKey: string | null = null let ssgCacheKey: string | null = null
if ( if (
...@@ -575,7 +577,17 @@ export async function handler( ...@@ -575,7 +577,17 @@ export async function handler(
}) })
} }
const incrementalCache = getRequestMeta(req, 'incrementalCache') const incrementalCache =
getRequestMeta(req, 'incrementalCache') ||
(await routeModule.getIncrementalCache(
req,
nextConfig,
prerenderManifest,
isMinimalMode
))
incrementalCache?.resetRequestCache()
;(globalThis as any).__incrementalCache = incrementalCache
const doRender = async ({ const doRender = async ({
span, span,
......
...@@ -203,6 +203,19 @@ export async function handler( ...@@ -203,6 +203,19 @@ export async function handler(
const method = req.method || 'GET' const method = req.method || 'GET'
const tracer = getTracer() const tracer = getTracer()
const activeSpan = tracer.getActiveScopeSpan() const activeSpan = tracer.getActiveScopeSpan()
const isMinimalMode = Boolean(getRequestMeta(req, 'minimalMode'))
const incrementalCache =
getRequestMeta(req, 'incrementalCache') ||
(await routeModule.getIncrementalCache(
req,
nextConfig,
prerenderManifest,
isMinimalMode
))
incrementalCache?.resetRequestCache()
;(globalThis as any).__incrementalCache = incrementalCache
const context: AppRouteRouteHandlerContext = { const context: AppRouteRouteHandlerContext = {
params, params,
...@@ -213,7 +226,7 @@ export async function handler( ...@@ -213,7 +226,7 @@ export async function handler(
}, },
cacheComponents: Boolean(nextConfig.cacheComponents), cacheComponents: Boolean(nextConfig.cacheComponents),
supportsDynamicResponse, supportsDynamicResponse,
incrementalCache: getRequestMeta(req, 'incrementalCache'), incrementalCache,
cacheLifeProfiles: nextConfig.cacheLife, cacheLifeProfiles: nextConfig.cacheLife,
waitUntil: ctx.waitUntil, waitUntil: ctx.waitUntil,
onClose: (cb) => { onClose: (cb) => {
...@@ -289,7 +302,6 @@ export async function handler( ...@@ -289,7 +302,6 @@ export async function handler(
} }
}) })
} }
const isMinimalMode = Boolean(getRequestMeta(req, 'minimalMode'))
const handleResponse = async (currentSpan?: Span) => { const handleResponse = async (currentSpan?: Span) => {
const responseGenerator: ResponseGenerator = async ({ const responseGenerator: ResponseGenerator = async ({
......
...@@ -118,7 +118,6 @@ import { AsyncCallbackSet } from './lib/async-callback-set' ...@@ -118,7 +118,6 @@ import { AsyncCallbackSet } from './lib/async-callback-set'
import { initializeCacheHandlers, setCacheHandler } from './use-cache/handlers' import { initializeCacheHandlers, setCacheHandler } from './use-cache/handlers'
import type { UnwrapPromise } from '../lib/coalesced-function' import type { UnwrapPromise } from '../lib/coalesced-function'
import { populateStaticEnv } from '../lib/static-env' import { populateStaticEnv } from '../lib/static-env'
import { isPostpone } from './lib/router-utils/is-postpone'
import { NodeModuleLoader } from './lib/module-loader/node-module-loader' import { NodeModuleLoader } from './lib/module-loader/node-module-loader'
import { NoFallbackError } from '../shared/lib/no-fallback-error.external' import { NoFallbackError } from '../shared/lib/no-fallback-error.external'
import { import {
...@@ -130,6 +129,7 @@ import { ...@@ -130,6 +129,7 @@ import {
routerServerGlobal, routerServerGlobal,
} from './lib/router-utils/router-server-context' } from './lib/router-utils/router-server-context'
import { installGlobalBehaviors } from './node-environment-extensions/global-behaviors' import { installGlobalBehaviors } from './node-environment-extensions/global-behaviors'
import { installProcessErrorHandlers } from './node-environment-extensions/process-error-handlers'
export * from './base-server' export * from './base-server'
...@@ -170,88 +170,6 @@ function getMiddlewareMatcher( ...@@ -170,88 +170,6 @@ function getMiddlewareMatcher(
return matcher return matcher
} }
function installProcessErrorHandlers(
shouldRemoveUncaughtErrorAndRejectionListeners: boolean
) {
// The conventional wisdom of Node.js and other runtimes is to treat
// unhandled errors as fatal and exit the process.
//
// But Next.js is not a generic JS runtime — it's a specialized runtime for
// React Server Components.
//
// Many unhandled rejections are due to the late-awaiting pattern for
// prefetching data. In Next.js it's OK to call an async function without
// immediately awaiting it, to start the request as soon as possible
// without blocking unncessarily on the result. These can end up
// triggering an "unhandledRejection" if it later turns out that the
// data is not needed to render the page. Example:
//
// const promise = fetchData()
// const shouldShow = await checkCondition()
// if (shouldShow) {
// return <Component promise={promise} />
// }
//
// In this example, `fetchData` is called immediately to start the request
// as soon as possible, but if `shouldShow` is false, then it will be
// discarded without unwrapping its result. If it errors, it will trigger
// an "unhandledRejection" event.
//
// Ideally, we would suppress these rejections completely without warning,
// because we don't consider them real errors. (TODO: Currently we do warn.)
//
// But regardless of whether we do or don't warn, we definitely shouldn't
// crash the entire process.
//
// Even a "legit" unhandled error unrelated to prefetching shouldn't
// prevent the rest of the page from rendering.
//
// So, we're going to intentionally override the default error handling
// behavior of the outer JS runtime to be more forgiving
// Remove any existing "unhandledRejection" and "uncaughtException" handlers.
// This is gated behind an experimental flag until we've considered the impact
// in various deployment environments. It's possible this may always need to
// be configurable.
if (shouldRemoveUncaughtErrorAndRejectionListeners) {
process.removeAllListeners('uncaughtException')
process.removeAllListeners('unhandledRejection')
}
// Install a new handler to prevent the process from crashing.
process.on('unhandledRejection', (reason: unknown) => {
if (isPostpone(reason)) {
// React postpones that are unhandled might end up logged here but they're
// not really errors. They're just part of rendering.
return
}
// Immediately log the error.
// TODO: Ideally, if we knew that this error was triggered by application
// code, we would suppress it entirely without logging. We can't reliably
// detect all of these, but when cacheComponents is enabled, we could suppress
// at least some of them by waiting to log the error until after all in-
// progress renders have completed. Then, only log errors for which there
// was not a corresponding "rejectionHandled" event.
console.error(reason)
})
process.on('rejectionHandled', () => {
// TODO: See note in the unhandledRejection handler above. In the future,
// we may use the "rejectionHandled" event to de-queue an error from
// being logged.
})
// Unhandled exceptions are errors triggered by non-async functions, so this
// is unrelated to the late-awaiting pattern. However, for similar reasons,
// we still shouldn't crash the process. Just log it.
process.on('uncaughtException', (reason: unknown) => {
if (isPostpone(reason)) {
return
}
console.error(reason)
})
}
export default class NextNodeServer extends BaseServer< export default class NextNodeServer extends BaseServer<
Options, Options,
NodeNextRequest, NodeNextRequest,
......
import { isPostpone } from '../lib/router-utils/is-postpone'
let _global = globalThis as typeof globalThis & {
nextInitializedProcessErrorHandlers?: boolean
}
export function installProcessErrorHandlers(
shouldRemoveUncaughtErrorAndRejectionListeners: boolean
) {
if (_global.nextInitializedProcessErrorHandlers) return
_global.nextInitializedProcessErrorHandlers = true
// The conventional wisdom of Node.js and other runtimes is to treat
// unhandled errors as fatal and exit the process.
//
// But Next.js is not a generic JS runtime — it's a specialized runtime for
// React Server Components.
//
// Many unhandled rejections are due to the late-awaiting pattern for
// prefetching data. In Next.js it's OK to call an async function without
// immediately awaiting it, to start the request as soon as possible
// without blocking unncessarily on the result. These can end up
// triggering an "unhandledRejection" if it later turns out that the
// data is not needed to render the page. Example:
//
// const promise = fetchData()
// const shouldShow = await checkCondition()
// if (shouldShow) {
// return <Component promise={promise} />
// }
//
// In this example, `fetchData` is called immediately to start the request
// as soon as possible, but if `shouldShow` is false, then it will be
// discarded without unwrapping its result. If it errors, it will trigger
// an "unhandledRejection" event.
//
// Ideally, we would suppress these rejections completely without warning,
// because we don't consider them real errors. (TODO: Currently we do warn.)
//
// But regardless of whether we do or don't warn, we definitely shouldn't
// crash the entire process.
//
// Even a "legit" unhandled error unrelated to prefetching shouldn't
// prevent the rest of the page from rendering.
//
// So, we're going to intentionally override the default error handling
// behavior of the outer JS runtime to be more forgiving
// Remove any existing "unhandledRejection" and "uncaughtException" handlers.
// This is gated behind an experimental flag until we've considered the impact
// in various deployment environments. It's possible this may always need to
// be configurable.
if (shouldRemoveUncaughtErrorAndRejectionListeners) {
process.removeAllListeners('uncaughtException')
process.removeAllListeners('unhandledRejection')
}
// Install a new handler to prevent the process from crashing.
process.on('unhandledRejection', (reason: unknown) => {
if (isPostpone(reason)) {
// React postpones that are unhandled might end up logged here but they're
// not really errors. They're just part of rendering.
return
}
// Immediately log the error.
// TODO: Ideally, if we knew that this error was triggered by application
// code, we would suppress it entirely without logging. We can't reliably
// detect all of these, but when cacheComponents is enabled, we could suppress
// at least some of them by waiting to log the error until after all in-
// progress renders have completed. Then, only log errors for which there
// was not a corresponding "rejectionHandled" event.
console.error(reason)
})
process.on('rejectionHandled', () => {
// TODO: See note in the unhandledRejection handler above. In the future,
// we may use the "rejectionHandled" event to de-queue an error from
// being logged.
})
// Unhandled exceptions are errors triggered by non-async functions, so this
// is unrelated to the late-awaiting pattern. However, for similar reasons,
// we still shouldn't crash the process. Just log it.
process.on('uncaughtException', (reason: unknown) => {
if (isPostpone(reason)) {
return
}
console.error(reason)
})
}
...@@ -630,12 +630,35 @@ export abstract class RouteModule< ...@@ -630,12 +630,35 @@ export abstract class RouteModule<
const { routesManifest, prerenderManifest, serverFilesManifest } = manifests const { routesManifest, prerenderManifest, serverFilesManifest } = manifests
const { basePath, i18n, rewrites } = routesManifest const { basePath, i18n, rewrites } = routesManifest
const relativeProjectDir =
getRequestMeta(req, 'relativeProjectDir') || this.relativeProjectDir
const routerServerContext =
routerServerGlobal[RouterServerContextSymbol]?.[relativeProjectDir]
const nextConfig =
routerServerContext?.nextConfig || serverFilesManifest?.config
// Injected in base-server.ts
const protocol = req.headers['x-forwarded-proto']?.includes('https')
? 'https'
: 'http'
// When there are hostname and port we build an absolute URL
if (!getRequestMeta(req, 'initURL')) {
const initUrl = serverFilesManifest?.config.experimental.trustHostHeader
? `${protocol}://${req.headers.host || 'localhost'}${req.url}`
: `${protocol}://${routerServerContext?.hostname || 'localhost'}${req.url}`
addRequestMeta(req, 'initURL', initUrl)
addRequestMeta(req, 'initProtocol', protocol)
}
if (basePath) { if (basePath) {
req.url = removePathPrefix(req.url || '/', basePath) req.url = removePathPrefix(req.url || '/', basePath)
} }
const parsedUrl = parseReqUrl(req.url || '/') const parsedUrl = parseReqUrl(req.url || '/')
addRequestMeta(req, 'initQuery', { ...parsedUrl?.query })
// if we couldn't parse the URL we can't continue // if we couldn't parse the URL we can't continue
if (!parsedUrl) { if (!parsedUrl) {
return return
...@@ -815,12 +838,14 @@ export abstract class RouteModule< ...@@ -815,12 +838,14 @@ export abstract class RouteModule<
if ( if (
// if both query and params are valid but one // if both query and params are valid but one
// provided more information rely on that one // provided more information and the query params
// were nxtP prefixed rely on that one
query && query &&
params && params &&
paramsResult.hasValidParams && paramsResult.hasValidParams &&
queryResult.hasValidParams && queryResult.hasValidParams &&
Object.keys(paramsResult.params).length < routeParamKeys.size > 0 &&
Object.keys(paramsResult.params).length <=
Object.keys(queryResult.params).length Object.keys(queryResult.params).length
) { ) {
paramsToInterpolate = queryResult.params paramsToInterpolate = queryResult.params
...@@ -880,6 +905,15 @@ export abstract class RouteModule< ...@@ -880,6 +905,15 @@ export abstract class RouteModule<
for (const key of routeParamKeys) { for (const key of routeParamKeys) {
if (!(key in originalQuery)) { if (!(key in originalQuery)) {
delete query[key] delete query[key]
// handle the case where there's collision and we
// normalized nxtPid=123 -> id=123 but user also
// sends id=456 as separate key
} else if (
originalQuery[key] &&
query[key] &&
originalQuery[key] !== query[key]
) {
query[key] = originalQuery[key]
} }
} }
...@@ -903,18 +937,21 @@ export abstract class RouteModule< ...@@ -903,18 +937,21 @@ export abstract class RouteModule<
isDraftMode = previewData !== false isDraftMode = previewData !== false
} }
const relativeProjectDir =
getRequestMeta(req, 'relativeProjectDir') || this.relativeProjectDir
const routerServerContext =
routerServerGlobal[RouterServerContextSymbol]?.[relativeProjectDir]
const nextConfig =
routerServerContext?.nextConfig || serverFilesManifest?.config
if (!nextConfig) { if (!nextConfig) {
throw new Error("Invariant: nextConfig couldn't be loaded") throw new Error("Invariant: nextConfig couldn't be loaded")
} }
if (process.env.NEXT_RUNTIME !== 'edge') {
const { installProcessErrorHandlers } =
require('../node-environment-extensions/process-error-handlers') as typeof import('../node-environment-extensions/process-error-handlers')
installProcessErrorHandlers(
Boolean(
nextConfig.experimental.removeUncaughtErrorAndRejectionListeners
)
)
}
let resolvedPathname = normalizedSrcPage let resolvedPathname = normalizedSrcPage
if (isDynamicRoute(resolvedPathname) && params) { if (isDynamicRoute(resolvedPathname) && params) {
resolvedPathname = serverUtils.interpolateDynamicPath( resolvedPathname = serverUtils.interpolateDynamicPath(
...@@ -926,6 +963,17 @@ export abstract class RouteModule< ...@@ -926,6 +963,17 @@ export abstract class RouteModule<
if (resolvedPathname === '/index') { if (resolvedPathname === '/index') {
resolvedPathname = '/' resolvedPathname = '/'
} }
if (
res &&
Boolean(req.headers['x-nextjs-data']) &&
(!res.statusCode || res.statusCode === 200)
) {
res.setHeader(
'x-nextjs-matched-path',
removeTrailingSlash(`${locale ? `/${locale}` : ''}${normalizedSrcPage}`)
)
}
const encodedResolvedPathname = resolvedPathname const encodedResolvedPathname = resolvedPathname
// we decode for cache key/manifest usage encoded is // we decode for cache key/manifest usage encoded is
......
...@@ -61,10 +61,6 @@ const myAdapter = { ...@@ -61,10 +61,6 @@ const myAdapter = {
`Missing fallback file for prerender ${output.id}: ${JSON.stringify(output, null, 2)}` `Missing fallback file for prerender ${output.id}: ${JSON.stringify(output, null, 2)}`
) )
} }
} else if (!output.fallback.postponedState) {
throw new Error(
`Missing postponed state or filePath for prerender ${output.id} ${JSON.stringify(output, null, 2)}`
)
} }
} }
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
const nextConfig = { const nextConfig = {
cacheComponents: true, cacheComponents: true,
experimental: { experimental: {
adapterPath: require.resolve('./my-adapter.mjs'), adapterPath:
process.env.NEXT_ADAPTER_PATH ?? require.resolve('./my-adapter.mjs'),
}, },
} }
......
...@@ -275,9 +275,13 @@ export class NextInstance { ...@@ -275,9 +275,13 @@ export class NextInstance {
}, },
...(this.resolutions ? { resolutions: this.resolutions } : {}), ...(this.resolutions ? { resolutions: this.resolutions } : {}),
scripts: { scripts: {
// since we can't get the build id as a build artifact, make it ...(isNextDeploy
// available under the static files ? // since we can't get the build id as a build artifact,
'post-build': `cp ${this.distDir}/BUILD_ID ${this.distDir}/static/__BUILD_ID`, // add it in build logs
{
'post-build': `node -e 'console.log("BUILD" + "_ID: " + require("fs").readFileSync("${this.distDir}/BUILD_ID"))'`,
}
: {}),
...pkgScripts, ...pkgScripts,
build: build:
(pkgScripts['build'] || this.buildCommand || 'next build') + (pkgScripts['build'] || this.buildCommand || 'next build') +
......
...@@ -8,7 +8,6 @@ import { ...@@ -8,7 +8,6 @@ import {
TEST_TEAM_NAME, TEST_TEAM_NAME,
TEST_TOKEN, TEST_TOKEN,
} from '../../../scripts/reset-project.mjs' } from '../../../scripts/reset-project.mjs'
import fetch from 'node-fetch'
import { Span } from 'next/dist/trace' import { Span } from 'next/dist/trace'
export class NextDeployInstance extends NextInstance { export class NextDeployInstance extends NextInstance {
...@@ -141,6 +140,9 @@ export class NextDeployInstance extends NextInstance { ...@@ -141,6 +140,9 @@ export class NextDeployInstance extends NextInstance {
if (process.env.IS_WEBPACK_TEST) { if (process.env.IS_WEBPACK_TEST) {
additionalEnv.push(`IS_WEBPACK_TEST=1`) additionalEnv.push(`IS_WEBPACK_TEST=1`)
} }
if (process.env.NEXT_ENABLE_ADAPTER) {
additionalEnv.push(`NEXT_ENABLE_ADAPTER=1`)
}
const deployRes = await execa( const deployRes = await execa(
'vercel', 'vercel',
...@@ -214,20 +216,6 @@ export class NextDeployInstance extends NextInstance { ...@@ -214,20 +216,6 @@ export class NextDeployInstance extends NextInstance {
} }
require('console').log(`Deployment URL: ${this._url}`) require('console').log(`Deployment URL: ${this._url}`)
const buildIdUrl = `${this._url}${
this.basePath || ''
}/_next/static/__BUILD_ID`
const buildIdRes = await fetch(buildIdUrl)
if (!buildIdRes.ok) {
require('console').error(
`Failed to load buildId ${buildIdUrl} (${buildIdRes.status})`
)
}
this._buildId = (await buildIdRes.text()).trim()
require('console').log(`Got buildId: ${this._buildId}`)
// Use the vercel inspect command to get the CLI output from the build. // Use the vercel inspect command to get the CLI output from the build.
const buildLogs = await execa( const buildLogs = await execa(
...@@ -241,13 +229,20 @@ export class NextDeployInstance extends NextInstance { ...@@ -241,13 +229,20 @@ export class NextDeployInstance extends NextInstance {
if (buildLogs.exitCode !== 0) { if (buildLogs.exitCode !== 0) {
throw new Error(`Failed to get build output logs: ${buildLogs.stderr}`) throw new Error(`Failed to get build output logs: ${buildLogs.stderr}`)
} }
// Use the stdout from the logs command as the CLI output. The CLI will
// output other unrelated logs to stderr.
// TODO: Combine with runtime logs (via `vercel logs`) // TODO: Combine with runtime logs (via `vercel logs`)
// Build logs seem to be piped to stderr, so we'll combine them to make sure we get all the logs. // Build logs seem to be piped to stderr, so we'll combine them to make sure we get all the logs.
this._cliOutput = buildLogs.stdout + buildLogs.stderr this._cliOutput = buildLogs.stdout + buildLogs.stderr
const buildId = this._cliOutput.match(/BUILD_ID: (.+)/)?.[1]?.trim()
if (!buildId) {
throw new Error(`Failed to get buildId from logs ${this._cliOutput}`)
}
this._buildId = buildId
require('console').log(`Got buildId: ${this._buildId}`)
// Use the stdout from the logs command as the CLI output. The CLI will
// output other unrelated logs to stderr.
} }
public async destroy() { public async destroy() {
......
...@@ -63,7 +63,7 @@ const myAdapter = { ...@@ -63,7 +63,7 @@ const myAdapter = {
) )
} }
} else if (!output.fallback.postponedState) { } else if (!output.fallback.postponedState) {
throw new Error( console.error(
`Missing postponed state or filePath for prerender ${output.id} ${JSON.stringify(output, null, 2)}` `Missing postponed state or filePath for prerender ${output.id} ${JSON.stringify(output, null, 2)}`
) )
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment