@lowdefy/server-dev 0.0.0-experimental-20260928120643 → 0.0.0-experimental-20260929101721

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -106,9 +106,12 @@ async function createLowdefyContext({ c, user }) {
106
106
  },
107
107
  scrubSecrets,
108
108
  secrets,
109
- // Aborts when the client disconnects before the response is sent. The dev server
110
- // has no request timeout.
111
- signal: createRequestSignal({ clientSignal: c.req.raw.signal }),
109
+ // Aborts when the client disconnects before the response is sent, or when the
110
+ // request timeout (src/middleware/requestTimeout.js) answers first.
111
+ signal: createRequestSignal({
112
+ clientSignal: c.req.raw.signal,
113
+ timeoutSignal: c.get('requestTimeoutSignal'),
114
+ }),
112
115
  steps,
113
116
  websockets,
114
117
  };
@@ -27,7 +27,9 @@ process.env.LOWDEFY_SECRET_TEST = secret;
27
27
 
28
28
  jest.unstable_mockModule('@lowdefy/api', () => ({
29
29
  createApiContext: jest.fn(),
30
- createRequestSignal: jest.fn(({ clientSignal }) => clientSignal),
30
+ createRequestSignal: jest.fn(({ clientSignal, timeoutSignal }) =>
31
+ timeoutSignal ? AbortSignal.any([clientSignal, timeoutSignal]) : clientSignal
32
+ ),
31
33
  // Returns what the server passes, so the test reads the auth-hook system context inputs.
32
34
  createSystemContext: jest.fn((options) => options),
33
35
  ensureMcpOauthResource: jest.fn(async () => {}),
@@ -107,8 +109,10 @@ afterAll(() => {
107
109
  const { default: createLowdefyContext } = await import('./createLowdefyContext.js');
108
110
  const { default: createSystemContext } = await import('./auth/createSystemContext.js');
109
111
 
110
- function createHonoContext({ path: reqPath = '/api/request/foo' } = {}) {
112
+ function createHonoContext({ path: reqPath = '/api/request/foo', requestTimeoutSignal } = {}) {
113
+ const variables = { requestTimeoutSignal };
111
114
  return {
115
+ get: (key) => variables[key],
112
116
  req: {
113
117
  header: (name) => (name ? undefined : {}),
114
118
  path: reqPath,
@@ -130,6 +134,17 @@ test('createLowdefyContext cancels the request work with the incoming request si
130
134
  expect(context.signal).toBe(c.req.raw.signal);
131
135
  });
132
136
 
137
+ test('createLowdefyContext cancels the request work when the request timeout answers first', async () => {
138
+ const timeout = new AbortController();
139
+ const c = createHonoContext({ requestTimeoutSignal: timeout.signal });
140
+ const context = await createLowdefyContext({ c });
141
+ expect(context.signal.aborted).toBe(false);
142
+ const reason = new DOMException('The request timeout of 20ms was exceeded.', 'TimeoutError');
143
+ timeout.abort(reason);
144
+ expect(context.signal.aborted).toBe(true);
145
+ expect(context.signal.reason).toBe(reason);
146
+ });
147
+
133
148
  test('createLowdefyContext scrubSecrets redacts a planted secret', async () => {
134
149
  const context = await createLowdefyContext({ c: createHonoContext() });
135
150
  expect(context.scrubSecrets(`token ${secret} end`)).toEqual('token [REDACTED] end');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server-dev",
3
- "version": "0.0.0-experimental-20260928120643",
3
+ "version": "0.0.0-experimental-20260929101721",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -45,40 +45,40 @@
45
45
  "@hono/mcp": "0.3.0",
46
46
  "@hono/node-server": "2.0.10",
47
47
  "@hono/vite-dev-server": "0.26.0",
48
- "@lowdefy/actions-core": "0.0.0-experimental-20260928120643",
49
- "@lowdefy/api": "0.0.0-experimental-20260928120643",
50
- "@lowdefy/block-utils": "0.0.0-experimental-20260928120643",
51
- "@lowdefy/blocks-aggrid": "0.0.0-experimental-20260928120643",
52
- "@lowdefy/blocks-antd": "0.0.0-experimental-20260928120643",
53
- "@lowdefy/blocks-antd-x": "0.0.0-experimental-20260928120643",
54
- "@lowdefy/blocks-basic": "0.0.0-experimental-20260928120643",
55
- "@lowdefy/blocks-captcha": "0.0.0-experimental-20260928120643",
56
- "@lowdefy/blocks-echarts": "0.0.0-experimental-20260928120643",
57
- "@lowdefy/blocks-loaders": "0.0.0-experimental-20260928120643",
58
- "@lowdefy/blocks-markdown": "0.0.0-experimental-20260928120643",
59
- "@lowdefy/blocks-tiptap": "0.0.0-experimental-20260928120643",
60
- "@lowdefy/build": "0.0.0-experimental-20260928120643",
61
- "@lowdefy/client": "0.0.0-experimental-20260928120643",
62
- "@lowdefy/connection-axios-http": "0.0.0-experimental-20260928120643",
63
- "@lowdefy/connection-mongodb": "0.0.0-experimental-20260928120643",
64
- "@lowdefy/docs-content": "0.0.0-experimental-20260928120643",
65
- "@lowdefy/e2e-utils": "0.0.0-experimental-20260928120643",
66
- "@lowdefy/errors": "0.0.0-experimental-20260928120643",
67
- "@lowdefy/helpers": "0.0.0-experimental-20260928120643",
68
- "@lowdefy/layout": "0.0.0-experimental-20260928120643",
69
- "@lowdefy/logger": "0.0.0-experimental-20260928120643",
70
- "@lowdefy/node-utils": "0.0.0-experimental-20260928120643",
71
- "@lowdefy/operators-change-case": "0.0.0-experimental-20260928120643",
72
- "@lowdefy/operators-cron": "0.0.0-experimental-20260928120643",
73
- "@lowdefy/operators-dayjs": "0.0.0-experimental-20260928120643",
74
- "@lowdefy/operators-diff": "0.0.0-experimental-20260928120643",
75
- "@lowdefy/operators-js": "0.0.0-experimental-20260928120643",
76
- "@lowdefy/operators-mql": "0.0.0-experimental-20260928120643",
77
- "@lowdefy/operators-nunjucks": "0.0.0-experimental-20260928120643",
78
- "@lowdefy/operators-uuid": "0.0.0-experimental-20260928120643",
79
- "@lowdefy/operators-yaml": "0.0.0-experimental-20260928120643",
80
- "@lowdefy/plugin-better-auth": "0.0.0-experimental-20260928120643",
81
- "@lowdefy/websockets-core": "0.0.0-experimental-20260928120643",
48
+ "@lowdefy/actions-core": "0.0.0-experimental-20260929101721",
49
+ "@lowdefy/api": "0.0.0-experimental-20260929101721",
50
+ "@lowdefy/block-utils": "0.0.0-experimental-20260929101721",
51
+ "@lowdefy/blocks-aggrid": "0.0.0-experimental-20260929101721",
52
+ "@lowdefy/blocks-antd": "0.0.0-experimental-20260929101721",
53
+ "@lowdefy/blocks-antd-x": "0.0.0-experimental-20260929101721",
54
+ "@lowdefy/blocks-basic": "0.0.0-experimental-20260929101721",
55
+ "@lowdefy/blocks-captcha": "0.0.0-experimental-20260929101721",
56
+ "@lowdefy/blocks-echarts": "0.0.0-experimental-20260929101721",
57
+ "@lowdefy/blocks-loaders": "0.0.0-experimental-20260929101721",
58
+ "@lowdefy/blocks-markdown": "0.0.0-experimental-20260929101721",
59
+ "@lowdefy/blocks-tiptap": "0.0.0-experimental-20260929101721",
60
+ "@lowdefy/build": "0.0.0-experimental-20260929101721",
61
+ "@lowdefy/client": "0.0.0-experimental-20260929101721",
62
+ "@lowdefy/connection-axios-http": "0.0.0-experimental-20260929101721",
63
+ "@lowdefy/connection-mongodb": "0.0.0-experimental-20260929101721",
64
+ "@lowdefy/docs-content": "0.0.0-experimental-20260929101721",
65
+ "@lowdefy/e2e-utils": "0.0.0-experimental-20260929101721",
66
+ "@lowdefy/errors": "0.0.0-experimental-20260929101721",
67
+ "@lowdefy/helpers": "0.0.0-experimental-20260929101721",
68
+ "@lowdefy/layout": "0.0.0-experimental-20260929101721",
69
+ "@lowdefy/logger": "0.0.0-experimental-20260929101721",
70
+ "@lowdefy/node-utils": "0.0.0-experimental-20260929101721",
71
+ "@lowdefy/operators-change-case": "0.0.0-experimental-20260929101721",
72
+ "@lowdefy/operators-cron": "0.0.0-experimental-20260929101721",
73
+ "@lowdefy/operators-dayjs": "0.0.0-experimental-20260929101721",
74
+ "@lowdefy/operators-diff": "0.0.0-experimental-20260929101721",
75
+ "@lowdefy/operators-js": "0.0.0-experimental-20260929101721",
76
+ "@lowdefy/operators-mql": "0.0.0-experimental-20260929101721",
77
+ "@lowdefy/operators-nunjucks": "0.0.0-experimental-20260929101721",
78
+ "@lowdefy/operators-uuid": "0.0.0-experimental-20260929101721",
79
+ "@lowdefy/operators-yaml": "0.0.0-experimental-20260929101721",
80
+ "@lowdefy/plugin-better-auth": "0.0.0-experimental-20260929101721",
81
+ "@lowdefy/websockets-core": "0.0.0-experimental-20260929101721",
82
82
  "@modelcontextprotocol/sdk": "1.29.0",
83
83
  "@tailwindcss/postcss": "4.3.3",
84
84
  "@vitejs/plugin-react": "6.0.2",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server-dev",
3
- "version": "0.0.0-experimental-20260928120643",
3
+ "version": "0.0.0-experimental-20260929101721",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -51,40 +51,40 @@
51
51
  "@hono/mcp": "0.3.0",
52
52
  "@hono/node-server": "2.0.10",
53
53
  "@hono/vite-dev-server": "0.26.0",
54
- "@lowdefy/actions-core": "0.0.0-experimental-20260928120643",
55
- "@lowdefy/api": "0.0.0-experimental-20260928120643",
56
- "@lowdefy/block-utils": "0.0.0-experimental-20260928120643",
57
- "@lowdefy/blocks-aggrid": "0.0.0-experimental-20260928120643",
58
- "@lowdefy/blocks-antd": "0.0.0-experimental-20260928120643",
59
- "@lowdefy/blocks-antd-x": "0.0.0-experimental-20260928120643",
60
- "@lowdefy/blocks-basic": "0.0.0-experimental-20260928120643",
61
- "@lowdefy/blocks-captcha": "0.0.0-experimental-20260928120643",
62
- "@lowdefy/blocks-echarts": "0.0.0-experimental-20260928120643",
63
- "@lowdefy/blocks-loaders": "0.0.0-experimental-20260928120643",
64
- "@lowdefy/blocks-markdown": "0.0.0-experimental-20260928120643",
65
- "@lowdefy/blocks-tiptap": "0.0.0-experimental-20260928120643",
66
- "@lowdefy/build": "0.0.0-experimental-20260928120643",
67
- "@lowdefy/client": "0.0.0-experimental-20260928120643",
68
- "@lowdefy/connection-axios-http": "0.0.0-experimental-20260928120643",
69
- "@lowdefy/connection-mongodb": "0.0.0-experimental-20260928120643",
70
- "@lowdefy/docs-content": "0.0.0-experimental-20260928120643",
71
- "@lowdefy/e2e-utils": "0.0.0-experimental-20260928120643",
72
- "@lowdefy/errors": "0.0.0-experimental-20260928120643",
73
- "@lowdefy/helpers": "0.0.0-experimental-20260928120643",
74
- "@lowdefy/layout": "0.0.0-experimental-20260928120643",
75
- "@lowdefy/logger": "0.0.0-experimental-20260928120643",
76
- "@lowdefy/node-utils": "0.0.0-experimental-20260928120643",
77
- "@lowdefy/operators-change-case": "0.0.0-experimental-20260928120643",
78
- "@lowdefy/operators-cron": "0.0.0-experimental-20260928120643",
79
- "@lowdefy/operators-dayjs": "0.0.0-experimental-20260928120643",
80
- "@lowdefy/operators-diff": "0.0.0-experimental-20260928120643",
81
- "@lowdefy/operators-js": "0.0.0-experimental-20260928120643",
82
- "@lowdefy/operators-mql": "0.0.0-experimental-20260928120643",
83
- "@lowdefy/operators-nunjucks": "0.0.0-experimental-20260928120643",
84
- "@lowdefy/operators-uuid": "0.0.0-experimental-20260928120643",
85
- "@lowdefy/operators-yaml": "0.0.0-experimental-20260928120643",
86
- "@lowdefy/plugin-better-auth": "0.0.0-experimental-20260928120643",
87
- "@lowdefy/websockets-core": "0.0.0-experimental-20260928120643",
54
+ "@lowdefy/actions-core": "0.0.0-experimental-20260929101721",
55
+ "@lowdefy/api": "0.0.0-experimental-20260929101721",
56
+ "@lowdefy/block-utils": "0.0.0-experimental-20260929101721",
57
+ "@lowdefy/blocks-aggrid": "0.0.0-experimental-20260929101721",
58
+ "@lowdefy/blocks-antd": "0.0.0-experimental-20260929101721",
59
+ "@lowdefy/blocks-antd-x": "0.0.0-experimental-20260929101721",
60
+ "@lowdefy/blocks-basic": "0.0.0-experimental-20260929101721",
61
+ "@lowdefy/blocks-captcha": "0.0.0-experimental-20260929101721",
62
+ "@lowdefy/blocks-echarts": "0.0.0-experimental-20260929101721",
63
+ "@lowdefy/blocks-loaders": "0.0.0-experimental-20260929101721",
64
+ "@lowdefy/blocks-markdown": "0.0.0-experimental-20260929101721",
65
+ "@lowdefy/blocks-tiptap": "0.0.0-experimental-20260929101721",
66
+ "@lowdefy/build": "0.0.0-experimental-20260929101721",
67
+ "@lowdefy/client": "0.0.0-experimental-20260929101721",
68
+ "@lowdefy/connection-axios-http": "0.0.0-experimental-20260929101721",
69
+ "@lowdefy/connection-mongodb": "0.0.0-experimental-20260929101721",
70
+ "@lowdefy/docs-content": "0.0.0-experimental-20260929101721",
71
+ "@lowdefy/e2e-utils": "0.0.0-experimental-20260929101721",
72
+ "@lowdefy/errors": "0.0.0-experimental-20260929101721",
73
+ "@lowdefy/helpers": "0.0.0-experimental-20260929101721",
74
+ "@lowdefy/layout": "0.0.0-experimental-20260929101721",
75
+ "@lowdefy/logger": "0.0.0-experimental-20260929101721",
76
+ "@lowdefy/node-utils": "0.0.0-experimental-20260929101721",
77
+ "@lowdefy/operators-change-case": "0.0.0-experimental-20260929101721",
78
+ "@lowdefy/operators-cron": "0.0.0-experimental-20260929101721",
79
+ "@lowdefy/operators-dayjs": "0.0.0-experimental-20260929101721",
80
+ "@lowdefy/operators-diff": "0.0.0-experimental-20260929101721",
81
+ "@lowdefy/operators-js": "0.0.0-experimental-20260929101721",
82
+ "@lowdefy/operators-mql": "0.0.0-experimental-20260929101721",
83
+ "@lowdefy/operators-nunjucks": "0.0.0-experimental-20260929101721",
84
+ "@lowdefy/operators-uuid": "0.0.0-experimental-20260929101721",
85
+ "@lowdefy/operators-yaml": "0.0.0-experimental-20260929101721",
86
+ "@lowdefy/plugin-better-auth": "0.0.0-experimental-20260929101721",
87
+ "@lowdefy/websockets-core": "0.0.0-experimental-20260929101721",
88
88
  "@modelcontextprotocol/sdk": "1.29.0",
89
89
  "@tailwindcss/postcss": "4.3.3",
90
90
  "@vitejs/plugin-react": "6.0.2",
package/src/app.js CHANGED
@@ -74,6 +74,7 @@ import pingHandler from './routes/ping.js';
74
74
  import reloadHandler from './routes/reload.js';
75
75
  import renderDevPage from './html/renderDevPage.js';
76
76
  import requestHandler from './routes/request.js';
77
+ import requestTimeout from './middleware/requestTimeout.js';
77
78
  import rootHandler from './routes/root.js';
78
79
  import staleFlag from './middleware/staleFlag.js';
79
80
  import usageHandler from './routes/usage.js';
@@ -82,6 +83,10 @@ import websocketHandler from './routes/websocket.js';
82
83
 
83
84
  const basePath = lowdefyConfig.basePath ?? '';
84
85
 
86
+ // Same default as the production server, so a request that would time out in production (a 504
87
+ // the page shows as a generic error, beside the other requests' results) also times out in dev.
88
+ const requestTimeoutMs = lowdefyConfig.requestTimeout ?? 30000;
89
+
85
90
  // Dev Hono app — mounted into Vite via @hono/vite-dev-server (Vite owns HTTP
86
91
  // and serves /client/* modules with HMR; everything else lands here).
87
92
  // No compression in dev (parity with the old next.config compress: false,
@@ -178,6 +183,19 @@ function createApp() {
178
183
  app.get('/lowdefy-docs/content/:slug{.+}', docsContentHandler);
179
184
  app.get('/lowdefy-docs/:kind', docsTypesHandler);
180
185
 
186
+ // Only the routes that run app logic: JIT page builds, the docs/MCP routes and the SSE streams
187
+ // are dev-only and can legitimately run longer than any production request.
188
+ if (requestTimeoutMs > 0) {
189
+ const timeoutMiddleware = requestTimeout({ timeoutMs: requestTimeoutMs });
190
+ [
191
+ '/api/request/*',
192
+ '/api/endpoints/*',
193
+ '/api/cron/*',
194
+ '/api/cron-forward/*',
195
+ '/api/detached/*',
196
+ ].forEach((route) => app.use(route, timeoutMiddleware));
197
+ }
198
+
181
199
  app.use('/api/*', apiContext());
182
200
  // Unified dev get-session: createLowdefyContext resolves the mock or headless
183
201
  // caller into context.user on every path, so read it here rather than
@@ -0,0 +1,38 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { HTTPException } from 'hono/http-exception';
18
+ import { timeout } from 'hono/timeout';
19
+
20
+ // Caps how long a request may run, and cancels the work it leaves behind. The 504 is
21
+ // answered while the handler is still running; the TimeoutError on the request's
22
+ // timeout signal (which apiContext folds into context.signal) cancels the upstream
23
+ // calls the handler is waiting on, such as an AI provider call, instead of letting
24
+ // them run, and bill, after the response has gone.
25
+ function requestTimeout({ timeoutMs }) {
26
+ return function requestTimeoutMiddleware(c, next) {
27
+ const controller = new AbortController();
28
+ c.set('requestTimeoutSignal', controller.signal);
29
+ return timeout(timeoutMs, () => {
30
+ controller.abort(
31
+ new DOMException(`The request timeout of ${timeoutMs}ms was exceeded.`, 'TimeoutError')
32
+ );
33
+ return new HTTPException(504, { message: 'Gateway Timeout' });
34
+ })(c, next);
35
+ };
36
+ }
37
+
38
+ export default requestTimeout;