Browse Source
- Create server.js with extended requestTimeout (10 min) for long-running fal.ai video generation - Update package.json dev script to use custom server - Add comments explaining why queue API is not used (file size limitations) - Use WHATWG URL API instead of deprecated url.parse()handoff-20260429-1057
3 changed files with 50 additions and 3 deletions
@ -0,0 +1,30 @@ |
|||
// Custom Next.js server with extended timeout for video generation
|
|||
// Node.js default server.requestTimeout is 5 minutes (300,000ms)
|
|||
// We extend it to 10 minutes for long-running fal.ai video generation
|
|||
|
|||
const { createServer } = require('http'); |
|||
const next = require('next'); |
|||
|
|||
const dev = process.env.NODE_ENV !== 'production'; |
|||
const hostname = 'localhost'; |
|||
const port = process.env.PORT || 3000; |
|||
|
|||
const app = next({ dev, hostname, port }); |
|||
const handle = app.getRequestHandler(); |
|||
|
|||
app.prepare().then(() => { |
|||
const server = createServer(async (req, res) => { |
|||
// Use WHATWG URL API instead of deprecated url.parse()
|
|||
const parsedUrl = new URL(req.url, `http://${hostname}:${port}`); |
|||
await handle(req, res, parsedUrl); |
|||
}); |
|||
|
|||
// Increase timeout to 10 minutes for long-running video generation
|
|||
server.requestTimeout = 600000; // 10 minutes
|
|||
server.headersTimeout = 610000; // Slightly longer than requestTimeout
|
|||
|
|||
server.listen(port, () => { |
|||
console.log(`> Ready on http://${hostname}:${port}`); |
|||
console.log(`> Server timeout set to ${server.requestTimeout / 1000 / 60} minutes`); |
|||
}); |
|||
}); |
|||
Loading…
Reference in new issue