Compare commits

..

2 Commits

Author SHA1 Message Date
Steven
0ceea76aa4 Publish Canary
- now@16.5.1-canary.0
 - @now/node-bridge@1.2.7-canary.0
2019-11-12 14:57:22 -05:00
Steven
897d11a1e1 [now-node] Disable default node timeout (#3300)
Node had a default [timeout](https://nodejs.org/api/http.html#http_server_timeout) of 2 minutes until Node 13.x so we'll need to manually disable the timeout so that the `maxDuration` config works properly.
2019-11-12 19:54:05 +00:00
5 changed files with 16 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "now",
"version": "16.5.0",
"version": "16.5.1-canary.0",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Now",

View File

@@ -141,6 +141,7 @@ export default class DevServer {
this.cachedNowConfig = null;
this.server = http.createServer(this.devServerHandler);
this.server.timeout = 0; // Disable timeout
this.serverUrlPrinted = false;
this.stopping = false;
this.buildMatches = new Map();

View File

@@ -2020,7 +2020,7 @@ test('fail to deploy a Lambda with a specific runtime but without a locked versi
t.is(output.exitCode, 1, formatOutput(output));
t.regex(
output.stderr,
/Function runtimes must have a valid version/gm,
/Function Runtimes must have a valid version/gim,
formatOutput(output)
);
});

View File

@@ -1,6 +1,6 @@
{
"name": "@now/node-bridge",
"version": "1.2.6",
"version": "1.2.7-canary.0",
"license": "MIT",
"main": "./index.js",
"repository": {

View File

@@ -5,7 +5,7 @@ import {
Server,
IncomingHttpHeaders,
OutgoingHttpHeaders,
request
request,
} from 'http';
interface NowProxyEvent {
@@ -29,6 +29,7 @@ export interface NowProxyResponse {
}
interface ServerLike {
timeout?: number;
listen: (
opts: {
host?: string;
@@ -132,16 +133,21 @@ export class Bridge {
}
listen() {
if (!this.server) {
const { server, resolveListening } = this;
if (!server) {
throw new Error('Server has not been set!');
}
const resolveListening = this.resolveListening;
if (typeof server.timeout === 'number' && server.timeout > 0) {
// Disable timeout (usually 2 minutes until Node 13).
// Instead, user should assign function `maxDuration`.
server.timeout = 0;
}
return this.server.listen(
return server.listen(
{
host: '127.0.0.1',
port: 0
port: 0,
},
function listeningCallback() {
if (!this || typeof this.address !== 'function') {
@@ -206,7 +212,7 @@ export class Bridge {
statusCode: response.statusCode || 200,
headers: response.headers,
body: bodyBuffer.toString('base64'),
encoding: 'base64'
encoding: 'base64',
});
});
});