-
Notifications
You must be signed in to change notification settings - Fork 30k
Open
Labels
linear: nextConfirmed issue that is tracked by the Next.js team.Confirmed issue that is tracked by the Next.js team.
Description
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 22.4.0: Mon Mar 6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000
Binaries:
Node: 18.15.0
npm: 9.5.0
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 13.4.4-canary.0
eslint-config-next: 13.4.3
react: 18.2.0
react-dom: 18.2.0
typescript: 5.0.4Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true)
Link to the code that reproduces this issue or a replay of the bug
https://github.com/slecoustre-vulog/bug-route-handler
To Reproduce
index.js
const {
https: { onRequest },
scheduler: { onSchedule },
logger,
} = require('firebase-functions/v2');
const { initializeApp } = require('firebase-admin/app');
const next = require('next');
const https = require('https');
const tools = require('normalize-diacritics');
const { parse } = require('url');
const LRU = require('lru-cache');
initializeApp();
const nextConfig = require('./next.config');
const nextAppsLRU = new LRU({
// TODO tune this
max: 3,
allowStale: true,
updateAgeOnGet: true,
dispose: (server) => {
server.close();
},
});
exports.web = onRequest(
{
concurrency: 300,
region: 'europe-west1',
minInstances: 1,
memory: '1GiB', // '512MB',
},
async (req, res) => {
const { hostname, protocol, url } = req;
const port = protocol === 'https' ? 443 : 80;
const key = [hostname, port].join(':');
let nextApp = nextAppsLRU.get(key);
if (!nextApp) {
nextApp = next({
...nextConfig,
dir: process.cwd(),
hostname,
port: process.env.NODE_ENV === 'development' ? 5001 : port,
});
nextAppsLRU.set(key, nextApp);
}
await nextApp.prepare();
const parsedUrl = parse(url, true);
await nextApp.getRequestHandler()(req, res, parsedUrl);
}
);
src/app/api/route.ts
import { NextRequest, NextResponse } from 'next/server';
export const GET = () => NextResponse.json({ message: 'Hello, world!' });
export const POST = async (req: NextRequest) => NextResponse.json({ message: 'Hello, world!', body: await req.json() });
Describe the Bug
During development everything works fine (npm run dev) but when you build and execute everything in firebase it doesn't work anymore.
but the same development worked very well in version 13.2.
in version :
- 13.4.2, I have the error: TypeError: Response body object should not be disturbed or locked
- canary, I have a timeout of 60s
If there is no Body then it works very well.
Expected Behavior
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
ameddin73, n00dl3s, m-j-g, piazzamp, tinkrtailor and 9 more
Metadata
Metadata
Assignees
Labels
linear: nextConfirmed issue that is tracked by the Next.js team.Confirmed issue that is tracked by the Next.js team.