From 1c81afbd9c161117f138708ff02dadf92322370c Mon Sep 17 00:00:00 2001 From: Joakim Kronqvist Date: Fri, 20 Apr 2018 13:48:12 +0300 Subject: [PATCH 1/4] Add timeout configuration possibilities --- scripts/dev | 1 + src/postgraphile/cli.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/scripts/dev b/scripts/dev index 6416639b31..8b3416b52b 100755 --- a/scripts/dev +++ b/scripts/dev @@ -17,6 +17,7 @@ else --watch src \ --ignore __tests__ \ --ignore __mocks__ \ + --timeout 5000 \ --ignore src/postgraphile/graphiql \ --ext js,ts \ --exec "$npm_bin/ts-node --ignore node_modules --disableWarnings src/postgraphile/cli.ts $* --show-error-stack json --extended-errors hint,detail,errcode" & diff --git a/src/postgraphile/cli.ts b/src/postgraphile/cli.ts index bf04ee5815..ca40f88b7b 100755 --- a/src/postgraphile/cli.ts +++ b/src/postgraphile/cli.ts @@ -125,6 +125,7 @@ program .option('-b, --disable-graphiql', 'disables the GraphiQL interface. overrides the GraphiQL route option') .option('-o, --cors', 'enable generous CORS settings. this is disabled by default, if possible use a proxy instead') .option('-l, --body-size-limit ', 'set the maximum size of JSON bodies that can be parsed (default 100kB) The size can be given as a human-readable string, such as \'200kB\' or \'5MB\' (case insensitive).') + .option('--timeout ', 'set the timeout value in milliseconds for sockets (defaults to 120000 = 2 minutes)', parseFloat) .option('--cluster-workers ', '[experimental] spawn workers to increase throughput', parseFloat) pluginHook('cli:flags:add:webserver', addFlag) @@ -192,6 +193,7 @@ const { schema: dbSchema, host: hostname = 'localhost', port = 5000, + timeout: serverTimeout = 120000, maxPoolSize, defaultRole: pgDefaultRole, graphql: graphqlRoute = '/graphql', @@ -422,6 +424,8 @@ if (noServer) { const rawMiddleware = postgraphile(pgConfig, schemas, postgraphileOptions) const middleware = pluginHook('cli:server:middleware', rawMiddleware, { options: postgraphileOptions }) const server = createServer(middleware) + server.setTimeout(serverTimeout, () => { return }) + pluginHook('cli:server:created', server, { options: postgraphileOptions, middleware }) // Start our server by listening to a specific port and host name. Also log From 24477e7343bebfbc783caff40239bec07f256eb2 Mon Sep 17 00:00:00 2001 From: Joakim Kronqvist Date: Mon, 23 Apr 2018 10:16:39 +0300 Subject: [PATCH 2/4] Use alternative syntax to set timeout for server --- src/postgraphile/cli.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/postgraphile/cli.ts b/src/postgraphile/cli.ts index ca40f88b7b..31d4d6f58d 100755 --- a/src/postgraphile/cli.ts +++ b/src/postgraphile/cli.ts @@ -424,7 +424,7 @@ if (noServer) { const rawMiddleware = postgraphile(pgConfig, schemas, postgraphileOptions) const middleware = pluginHook('cli:server:middleware', rawMiddleware, { options: postgraphileOptions }) const server = createServer(middleware) - server.setTimeout(serverTimeout, () => { return }) + server.timeout = serverTimeout pluginHook('cli:server:created', server, { options: postgraphileOptions, middleware }) From acfcd736e61d8a85e06c8e9d3397cc01cda7b3f4 Mon Sep 17 00:00:00 2001 From: Joakim Kronqvist Date: Mon, 23 Apr 2018 10:17:10 +0300 Subject: [PATCH 3/4] Remove development code for setting timeout --- scripts/dev | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/dev b/scripts/dev index 8b3416b52b..6416639b31 100755 --- a/scripts/dev +++ b/scripts/dev @@ -17,7 +17,6 @@ else --watch src \ --ignore __tests__ \ --ignore __mocks__ \ - --timeout 5000 \ --ignore src/postgraphile/graphiql \ --ext js,ts \ --exec "$npm_bin/ts-node --ignore node_modules --disableWarnings src/postgraphile/cli.ts $* --show-error-stack json --extended-errors hint,detail,errcode" & From 1dba7b3bd712e101275dbb563f2f5fb71c6cbfb5 Mon Sep 17 00:00:00 2001 From: Benjie Gillam Date: Fri, 20 Jul 2018 16:38:10 +0100 Subject: [PATCH 4/4] Don't specify default for timeout --- src/postgraphile/cli.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/postgraphile/cli.ts b/src/postgraphile/cli.ts index 31d4d6f58d..f1d78d873e 100755 --- a/src/postgraphile/cli.ts +++ b/src/postgraphile/cli.ts @@ -125,7 +125,7 @@ program .option('-b, --disable-graphiql', 'disables the GraphiQL interface. overrides the GraphiQL route option') .option('-o, --cors', 'enable generous CORS settings. this is disabled by default, if possible use a proxy instead') .option('-l, --body-size-limit ', 'set the maximum size of JSON bodies that can be parsed (default 100kB) The size can be given as a human-readable string, such as \'200kB\' or \'5MB\' (case insensitive).') - .option('--timeout ', 'set the timeout value in milliseconds for sockets (defaults to 120000 = 2 minutes)', parseFloat) + .option('--timeout ', 'set the timeout value in milliseconds for sockets', parseFloat) .option('--cluster-workers ', '[experimental] spawn workers to increase throughput', parseFloat) pluginHook('cli:flags:add:webserver', addFlag) @@ -193,7 +193,7 @@ const { schema: dbSchema, host: hostname = 'localhost', port = 5000, - timeout: serverTimeout = 120000, + timeout: serverTimeout, maxPoolSize, defaultRole: pgDefaultRole, graphql: graphqlRoute = '/graphql', @@ -424,7 +424,9 @@ if (noServer) { const rawMiddleware = postgraphile(pgConfig, schemas, postgraphileOptions) const middleware = pluginHook('cli:server:middleware', rawMiddleware, { options: postgraphileOptions }) const server = createServer(middleware) - server.timeout = serverTimeout + if (serverTimeout) { + server.timeout = serverTimeout + } pluginHook('cli:server:created', server, { options: postgraphileOptions, middleware })