dsh-ris-ide 1.7.3 → 1.8.0
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.
- package/README.md +19 -7
- package/bin/proxy-janitor.mjs +106 -11
- package/bin/risd.mjs +287 -0
- package/bin/run-with-log.ps1 +43 -5
- package/lib/client.js +515 -1152
- package/lib/index.js +1124 -55
- package/lib/janitor.js +106 -15
- package/lib/proxy.js +86 -7
- package/lib/proxybridge-bundle.js +798 -0
- package/lib/redirector.js +484 -35
- package/lib/risd/build.js +91 -0
- package/lib/risd/debug.js +374 -0
- package/lib/risd/git.js +207 -0
- package/lib/risd/leases.js +124 -0
- package/lib/risd/lifecycle.js +148 -0
- package/lib/risd/log.js +59 -0
- package/lib/risd/ping.js +94 -0
- package/lib/risd/programs.js +348 -0
- package/lib/risd/server.js +1478 -0
- package/lib/risd/state.js +137 -0
- package/lib/risd/ui.js +1705 -0
- package/lib/risd/view.js +79 -0
- package/lib/risd-client.js +282 -0
- package/lib/standalone/window.html +14 -16
- package/lib/startup.js +114 -0
- package/package.json +4 -1
- package/test/client-build.test.mjs +113 -0
- package/test/client-viewer.test.mjs +166 -200
- package/test/dsh-origin.test.mjs +140 -0
- package/test/dsh-window-refresh.test.mjs +100 -0
- package/test/harness.test.mjs +9 -0
- package/test/host-noloop.test.mjs +74 -0
- package/test/host-tail.test.mjs +21 -4
- package/test/host-window.test.mjs +4 -4
- package/test/janitor.test.mjs +29 -1
- package/test/lifecycle.test.mjs +26 -5
- package/test/merge-owners.test.mjs +155 -0
- package/test/proxy-restart.test.mjs +37 -0
- package/test/proxy-window.test.mjs +45 -0
- package/test/proxy.test.mjs +41 -0
- package/test/proxybridge-bundle.test.mjs +687 -0
- package/test/redirector-bundle.test.mjs +391 -0
- package/test/redirector.test.mjs +59 -9
- package/test/risd-api.test.mjs +470 -0
- package/test/risd-bridge-degrade.test.mjs +101 -0
- package/test/risd-build.test.mjs +20 -0
- package/test/risd-cli-home.test.mjs +50 -0
- package/test/risd-client.test.mjs +130 -0
- package/test/risd-debug.test.mjs +261 -0
- package/test/risd-election.test.mjs +104 -0
- package/test/risd-engine.test.mjs +132 -0
- package/test/risd-entry.test.mjs +118 -0
- package/test/risd-git.test.mjs +109 -0
- package/test/risd-handoff.test.mjs +116 -0
- package/test/risd-heal.test.mjs +50 -0
- package/test/risd-helpers.mjs +108 -0
- package/test/risd-host-p2.test.mjs +147 -0
- package/test/risd-janitor-guard.test.mjs +46 -0
- package/test/risd-lease.test.mjs +83 -0
- package/test/risd-lifecycle.test.mjs +210 -0
- package/test/risd-log-follow.test.mjs +227 -0
- package/test/risd-mode.test.mjs +161 -0
- package/test/risd-ping.test.mjs +99 -0
- package/test/risd-programs.test.mjs +169 -0
- package/test/risd-review-p2.test.mjs +217 -0
- package/test/risd-shutdown.test.mjs +97 -0
- package/test/risd-teardown.test.mjs +87 -0
- package/test/risd-tools.test.mjs +211 -0
- package/test/risd-ui.test.mjs +445 -0
- package/test/risd-write.test.mjs +170 -0
- package/test/startup-reconcile.test.mjs +100 -0
- package/test/windows.test.mjs +37 -2
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* risd API: authentication, apiVersion, read-only view, leases, shutdown.
|
|
3
|
+
*
|
|
4
|
+
* The daemon under test runs with `DSH_RIS_IDE_PROXY_HOME` pointed at its own
|
|
5
|
+
* temp home, so the machine's real `proxy.json` / janitor state is never read.
|
|
6
|
+
* That is also why the fixture writes a `proxy.json` by hand: the view must be
|
|
7
|
+
* derived from the machine table, and a test that consulted `~/.dsh-ris-ide`
|
|
8
|
+
* would not be a test at all.
|
|
9
|
+
*/
|
|
10
|
+
import assert from 'node:assert/strict'
|
|
11
|
+
import test from 'node:test'
|
|
12
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
13
|
+
import { join } from 'node:path'
|
|
14
|
+
import { tmpdir } from 'node:os'
|
|
15
|
+
import { createHash } from 'node:crypto'
|
|
16
|
+
import { gzipSync } from 'node:zlib'
|
|
17
|
+
import { RISD_API_VERSION, risdStatePath } from '../lib/risd/state.js'
|
|
18
|
+
import { bundleLayout } from '../lib/proxybridge-bundle.js'
|
|
19
|
+
import { readProxyConfig } from '../lib/proxy.js'
|
|
20
|
+
import { risdConfigRevision } from '../lib/risd/view.js'
|
|
21
|
+
import { configRevision } from '../lib/index.js'
|
|
22
|
+
import { makeHome, removeHome, startRisdProcess } from './risd-helpers.mjs'
|
|
23
|
+
|
|
24
|
+
const API_HEADER = 'x-risd-api-version'
|
|
25
|
+
|
|
26
|
+
const FIXTURE = {
|
|
27
|
+
socks: { host: 'proxy.example.com', port: 10080 },
|
|
28
|
+
listenPort: 11081,
|
|
29
|
+
rules: [
|
|
30
|
+
{ id: 'r1', program: 'git', hosts: 'git.example.com', ports: '*', enabled: true, shadow: false, source: 'user', workspace: '/tmp/ws' },
|
|
31
|
+
],
|
|
32
|
+
shadows: [],
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function call(state, path, { method = 'GET', body = undefined, token = state.token, apiVersion = RISD_API_VERSION } = {}) {
|
|
36
|
+
const headers = {}
|
|
37
|
+
if (token !== null) headers.authorization = `Bearer ${token}`
|
|
38
|
+
if (apiVersion !== null) headers[API_HEADER] = String(apiVersion)
|
|
39
|
+
if (body !== undefined) headers['content-type'] = 'application/json'
|
|
40
|
+
return fetch(`${state.url}${path}`, { method, headers, body: body === undefined ? undefined : JSON.stringify(body) })
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** A ustar entry for the in-test bundle fixture. */
|
|
44
|
+
function tarEntry(name, data) {
|
|
45
|
+
const header = Buffer.alloc(512)
|
|
46
|
+
header.write(name, 0, 100, 'utf8')
|
|
47
|
+
header.write('000644 \0', 100, 8, 'ascii')
|
|
48
|
+
header.write('0000000 \0', 108, 8, 'ascii')
|
|
49
|
+
header.write('0000000 \0', 116, 8, 'ascii')
|
|
50
|
+
header.write(`${data.length.toString(8).padStart(11, '0')} \0`, 124, 12, 'ascii')
|
|
51
|
+
header.write('00000000000 \0', 136, 12, 'ascii')
|
|
52
|
+
header.write(' ', 148, 8, 'ascii')
|
|
53
|
+
header.write('0', 156, 1, 'ascii')
|
|
54
|
+
header.write('ustar \0', 257, 6, 'ascii')
|
|
55
|
+
header.write('00', 263, 2, 'ascii')
|
|
56
|
+
let sum = 0
|
|
57
|
+
for (const byte of header) sum += byte
|
|
58
|
+
header.write(`${sum.toString(8).padStart(6, '0')} \0 `, 148, 8, 'ascii')
|
|
59
|
+
return Buffer.concat([header, data, Buffer.alloc((512 - (data.length % 512)) % 512)])
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A valid .tgz carrying exactly the eight files the installer requires. */
|
|
63
|
+
function bundleTgz() {
|
|
64
|
+
const parts = bundleLayout().map((name) => tarEntry(name, Buffer.from(`${name}\n`)))
|
|
65
|
+
parts.push(Buffer.alloc(1024))
|
|
66
|
+
return gzipSync(Buffer.concat(parts))
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** POST raw bytes to the upload route (the JSON body helper cannot carry a tgz). */
|
|
70
|
+
async function upload(state, bytes) {
|
|
71
|
+
return fetch(`${state.url}/v1/proxybridge/upload`, {
|
|
72
|
+
method: 'POST',
|
|
73
|
+
headers: {
|
|
74
|
+
authorization: `Bearer ${state.token}`,
|
|
75
|
+
[API_HEADER]: String(RISD_API_VERSION),
|
|
76
|
+
'content-type': 'application/gzip',
|
|
77
|
+
},
|
|
78
|
+
body: bytes,
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function startFixture(t) {
|
|
83
|
+
const home = makeHome('risd-api-')
|
|
84
|
+
const saved = process.env.DSH_RIS_IDE_PROXY_HOME
|
|
85
|
+
process.env.DSH_RIS_IDE_PROXY_HOME = home
|
|
86
|
+
t.after(() => {
|
|
87
|
+
if (saved === undefined) delete process.env.DSH_RIS_IDE_PROXY_HOME
|
|
88
|
+
else process.env.DSH_RIS_IDE_PROXY_HOME = saved
|
|
89
|
+
removeHome(home)
|
|
90
|
+
})
|
|
91
|
+
writeFileSync(join(home, 'proxy.json'), `${JSON.stringify(FIXTURE, null, 2)}\n`, { mode: 0o600 })
|
|
92
|
+
const daemon = await startRisdProcess({ home, env: { DSH_RIS_IDE_PROXY_HOME: home } })
|
|
93
|
+
t.after(() => daemon.stop())
|
|
94
|
+
return { home, daemon, state: daemon.state }
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
test('health is unauthenticated and reports the api version', async (t) => {
|
|
98
|
+
const { state } = await startFixture(t)
|
|
99
|
+
const response = await call(state, '/v1/health', { token: null, apiVersion: null })
|
|
100
|
+
assert.equal(response.status, 200)
|
|
101
|
+
const body = await response.json()
|
|
102
|
+
assert.equal(body.ok, true)
|
|
103
|
+
assert.equal(body.apiVersion, RISD_API_VERSION)
|
|
104
|
+
assert.equal(body.pid, state.pid)
|
|
105
|
+
assert.equal(body.port, state.port)
|
|
106
|
+
assert.equal(body.leases.count, 0)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
test('health names the daemon code this process runs and the code on disk (m09693)', async (t) => {
|
|
110
|
+
const { state } = await startFixture(t)
|
|
111
|
+
const body = await (await call(state, '/v1/health', { token: null, apiVersion: null })).json()
|
|
112
|
+
assert.equal(typeof body.uiBuild, 'object')
|
|
113
|
+
assert.match(body.uiBuild.loaded, /^[0-9a-f]{12}$/)
|
|
114
|
+
assert.match(body.uiBuild.disk, /^[0-9a-f]{12}$/)
|
|
115
|
+
// Nothing was edited between spawn and this request: the page must not think a
|
|
116
|
+
// restart is pending, or it would nag on every fresh daemon.
|
|
117
|
+
assert.equal(body.uiBuild.loaded, body.uiBuild.disk)
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
test('every other endpoint needs the token and the api header', async (t) => {
|
|
121
|
+
const { state } = await startFixture(t)
|
|
122
|
+
|
|
123
|
+
const noToken = await call(state, '/v1/status?cwd=/tmp/ws', { token: null })
|
|
124
|
+
assert.equal(noToken.status, 401)
|
|
125
|
+
assert.equal((await noToken.json()).code, 'unauthorized')
|
|
126
|
+
|
|
127
|
+
const wrongToken = await call(state, '/v1/status?cwd=/tmp/ws', { token: 'nope' })
|
|
128
|
+
assert.equal(wrongToken.status, 401)
|
|
129
|
+
|
|
130
|
+
const noVersion = await call(state, '/v1/status?cwd=/tmp/ws', { apiVersion: null })
|
|
131
|
+
assert.equal(noVersion.status, 409)
|
|
132
|
+
assert.equal((await noVersion.json()).code, 'api-mismatch')
|
|
133
|
+
|
|
134
|
+
const oldVersion = await call(state, '/v1/status?cwd=/tmp/ws', { apiVersion: 0 })
|
|
135
|
+
assert.equal(oldVersion.status, 409)
|
|
136
|
+
|
|
137
|
+
const ok = await call(state, '/v1/status?cwd=/tmp/ws')
|
|
138
|
+
assert.equal(ok.status, 200)
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
test('the read-only view matches the plugin revision and needs an absolute cwd', async (t) => {
|
|
142
|
+
const { home, state } = await startFixture(t)
|
|
143
|
+
|
|
144
|
+
const missing = await call(state, '/v1/status')
|
|
145
|
+
assert.equal(missing.status, 400)
|
|
146
|
+
assert.equal((await missing.json()).code, 'bad-request')
|
|
147
|
+
|
|
148
|
+
const relative = await call(state, '/v1/proxy?cwd=relative/path')
|
|
149
|
+
assert.equal(relative.status, 400)
|
|
150
|
+
|
|
151
|
+
const response = await call(state, '/v1/proxy?cwd=/tmp/ws')
|
|
152
|
+
assert.equal(response.status, 200)
|
|
153
|
+
const view = await response.json()
|
|
154
|
+
assert.equal(view.ok, true)
|
|
155
|
+
assert.equal(view.shared, true)
|
|
156
|
+
assert.equal(view.workspace, '/tmp/ws')
|
|
157
|
+
assert.equal(view.configPath, join(home, 'proxy.json'))
|
|
158
|
+
assert.equal(view.socks.host, 'proxy.example.com')
|
|
159
|
+
assert.equal(view.listenPort, 11081)
|
|
160
|
+
assert.equal(typeof view.revision, 'string')
|
|
161
|
+
assert.ok(Array.isArray(view.rules), 'the daemon ships raw rules for the maintenance page editor')
|
|
162
|
+
assert.deepEqual(view.rules.map((rule) => rule.id), readProxyConfig().rules.map((rule) => rule.id))
|
|
163
|
+
assert.equal(typeof view.redirector, 'object')
|
|
164
|
+
assert.equal(typeof view.janitor, 'object')
|
|
165
|
+
assert.equal(view.daemon.pid, state.pid)
|
|
166
|
+
|
|
167
|
+
const config = readProxyConfig()
|
|
168
|
+
assert.equal(risdConfigRevision(config), configRevision(config), 'daemon revision must equal the plugin revision')
|
|
169
|
+
assert.equal(view.revision, configRevision(config))
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
test('the payload is the whole table: rows it leaves out are retired (m10585)', async (t) => {
|
|
173
|
+
// The rule table is machine-wide and no longer partitioned by workspace or source:
|
|
174
|
+
// what the caller sends IS the table. A row nobody sent disappears, which is what
|
|
175
|
+
// lets `yds stop` clear its rows by omission and the panel overwrite an edit.
|
|
176
|
+
const { home, state } = await startFixture(t)
|
|
177
|
+
const ws = mkdtempSync(join(tmpdir(), 'risd-replace-ws-'))
|
|
178
|
+
const other = mkdtempSync(join(tmpdir(), 'risd-replace-other-'))
|
|
179
|
+
t.after(() => {
|
|
180
|
+
rmSync(ws, { recursive: true, force: true })
|
|
181
|
+
rmSync(other, { recursive: true, force: true })
|
|
182
|
+
})
|
|
183
|
+
const stored = readProxyConfig()
|
|
184
|
+
writeFileSync(join(home, 'proxy.json'), `${JSON.stringify(Object.assign({}, stored, {
|
|
185
|
+
rules: [
|
|
186
|
+
{ id: 'r1', program: 'git', hosts: 'git.example.com', ports: '*', enabled: true, source: 'user', workspace: ws },
|
|
187
|
+
{ id: 'yds-java', program: 'java', hosts: '10.0.0.*', ports: '*', enabled: true, source: 'yds', workspace: ws },
|
|
188
|
+
{ id: 'yds-other', program: 'java', hosts: '10.1.0.*', ports: '*', enabled: true, source: 'yds', workspace: other },
|
|
189
|
+
],
|
|
190
|
+
}), null, 2)}\n`, { mode: 0o600 })
|
|
191
|
+
const view = await (await call(state, `/v1/proxy?cwd=${encodeURIComponent(ws)}`)).json()
|
|
192
|
+
const userRule = view.rules.find((rule) => rule.id === 'r1')
|
|
193
|
+
const saved = await call(state, '/v1/proxy', {
|
|
194
|
+
method: 'POST',
|
|
195
|
+
body: {
|
|
196
|
+
cwd: ws,
|
|
197
|
+
config: { socks: view.socks, listenPort: view.listenPort, rules: [userRule] },
|
|
198
|
+
revision: view.revision,
|
|
199
|
+
},
|
|
200
|
+
})
|
|
201
|
+
assert.equal(saved.status, 200)
|
|
202
|
+
const after = await (await call(state, `/v1/proxy?cwd=${encodeURIComponent(ws)}`)).json()
|
|
203
|
+
assert.deepEqual(after.rules.map((rule) => rule.id).sort(), ['r1'],
|
|
204
|
+
'only the rows in the payload survive')
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
test('the ping route probes the configured SOCKS upstream and honours overrides', async (t) => {
|
|
208
|
+
// The proxy tab polls this every 10 s; it must answer with the SOCKS5 handshake
|
|
209
|
+
// outcome (not just "port open") and accept an edited-but-unsaved host/port.
|
|
210
|
+
const { createServer } = await import('node:net')
|
|
211
|
+
const socks = createServer((socket) => socket.once('data', () => socket.write(Buffer.from([0x05, 0x00]))))
|
|
212
|
+
await new Promise((resolve) => socks.listen(0, '127.0.0.1', resolve))
|
|
213
|
+
t.after(() => socks.close())
|
|
214
|
+
const { state } = await startFixture(t)
|
|
215
|
+
|
|
216
|
+
const port = socks.address().port
|
|
217
|
+
const response = await call(state, `/v1/proxy/ping?host=127.0.0.1&port=${port}`)
|
|
218
|
+
assert.equal(response.status, 200)
|
|
219
|
+
const body = await response.json()
|
|
220
|
+
assert.equal(body.ok, true)
|
|
221
|
+
assert.equal(body.socks, true)
|
|
222
|
+
assert.equal(body.port, port)
|
|
223
|
+
|
|
224
|
+
// Without overrides it probes the fixture's (unreachable) host and reports why.
|
|
225
|
+
const stored = await call(state, '/v1/proxy/ping')
|
|
226
|
+
assert.equal(stored.status, 200)
|
|
227
|
+
const storedBody = await stored.json()
|
|
228
|
+
assert.equal(storedBody.ok, false)
|
|
229
|
+
assert.equal(typeof storedBody.error, 'string')
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
test('the ProxyBridge bundle card reports status and rejects a bad upload', async (t) => {
|
|
233
|
+
const { state } = await startFixture(t)
|
|
234
|
+
|
|
235
|
+
const status = await call(state, '/v1/proxybridge')
|
|
236
|
+
assert.equal(status.status, 200)
|
|
237
|
+
const body = await status.json()
|
|
238
|
+
assert.equal(body.ok, true)
|
|
239
|
+
assert.equal(body.installed, false)
|
|
240
|
+
assert.equal(typeof body.dir, 'string')
|
|
241
|
+
assert.equal(typeof body.url, 'string')
|
|
242
|
+
assert.ok(Array.isArray(body.urls) && body.urls.length >= 2, 'both mirrors are offered')
|
|
243
|
+
assert.ok(body.urls[0].includes('gitee.com'), 'gitee is tried first')
|
|
244
|
+
assert.ok(body.urls[1].includes('github.com'), 'github is the fallback')
|
|
245
|
+
// The digest the next install must match, and whether what is on disk does
|
|
246
|
+
// (review B-P0-1). Nothing is installed here, so there is no "actual" yet.
|
|
247
|
+
assert.match(body.sha256, /^[0-9a-f]{64}$/, 'the pinned release digest is advertised')
|
|
248
|
+
assert.equal(body.actualSha256, null)
|
|
249
|
+
assert.equal(body.verified, false)
|
|
250
|
+
|
|
251
|
+
// A non-tar body is answered with a reason, not a crash or a half-installed dir.
|
|
252
|
+
const bad = await fetch(`${state.url}/v1/proxybridge/upload`, {
|
|
253
|
+
method: 'POST',
|
|
254
|
+
headers: { authorization: `Bearer ${state.token}`, [API_HEADER]: String(RISD_API_VERSION), 'content-type': 'application/gzip' },
|
|
255
|
+
body: Buffer.from('definitely not a gzipped tar'),
|
|
256
|
+
})
|
|
257
|
+
assert.equal(bad.status, 400)
|
|
258
|
+
const badBody = await bad.json()
|
|
259
|
+
assert.equal(badBody.ok, false)
|
|
260
|
+
assert.equal(typeof badBody.message, 'string')
|
|
261
|
+
})
|
|
262
|
+
|
|
263
|
+
test('leases are created, reused and released', async (t) => {
|
|
264
|
+
const { state } = await startFixture(t)
|
|
265
|
+
|
|
266
|
+
const first = await call(state, '/v1/leases', { method: 'POST', body: { ownerPid: process.pid, sessionId: 's1', cwd: '/tmp/ws' } })
|
|
267
|
+
assert.equal(first.status, 200)
|
|
268
|
+
const lease = (await first.json()).lease
|
|
269
|
+
assert.match(lease.id, /^[0-9a-f-]{36}$/)
|
|
270
|
+
assert.equal(lease.ownerPid, process.pid)
|
|
271
|
+
assert.equal(lease.sessionId, 's1')
|
|
272
|
+
|
|
273
|
+
const again = await call(state, '/v1/leases', { method: 'POST', body: { ownerPid: process.pid, sessionId: 's1', cwd: '/tmp/ws' } })
|
|
274
|
+
assert.equal((await again.json()).lease.id, lease.id, 'same owner/session/workspace reuses the lease')
|
|
275
|
+
|
|
276
|
+
const other = await call(state, '/v1/leases', { method: 'POST', body: { ownerPid: process.pid, sessionId: 's2', cwd: '/tmp/ws' } })
|
|
277
|
+
assert.notEqual((await other.json()).lease.id, lease.id)
|
|
278
|
+
|
|
279
|
+
const released = await call(state, `/v1/leases/${lease.id}`, { method: 'DELETE' })
|
|
280
|
+
assert.deepEqual(await released.json(), { ok: true, released: true })
|
|
281
|
+
const againReleased = await call(state, `/v1/leases/${lease.id}`, { method: 'DELETE' })
|
|
282
|
+
assert.deepEqual(await againReleased.json(), { ok: true, released: false })
|
|
283
|
+
|
|
284
|
+
const badPid = await call(state, '/v1/leases', { method: 'POST', body: { ownerPid: 'x' } })
|
|
285
|
+
assert.equal(badPid.status, 400)
|
|
286
|
+
const badCwd = await call(state, '/v1/leases', { method: 'POST', body: { ownerPid: process.pid, cwd: 'relative' } })
|
|
287
|
+
assert.equal(badCwd.status, 400)
|
|
288
|
+
const badJson = await call(state, '/v1/leases', { method: 'POST', body: 'not-an-object' })
|
|
289
|
+
assert.equal(badJson.status, 400)
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
test('config reports the decided policy and only accepts a lifecycle body', async (t) => {
|
|
293
|
+
const { state } = await startFixture(t)
|
|
294
|
+
const response = await call(state, '/v1/config')
|
|
295
|
+
assert.equal(response.status, 200)
|
|
296
|
+
const body = await response.json()
|
|
297
|
+
assert.equal(body.keepPolicy, 'session')
|
|
298
|
+
assert.equal(body.idleExitMs, 600000)
|
|
299
|
+
// The daemon has no restart supervisor; advertising one was a lie (review A-P2-3).
|
|
300
|
+
assert.equal(body.engineRestart, undefined)
|
|
301
|
+
assert.equal(body.lifecycle.daemon.followDsh, true)
|
|
302
|
+
|
|
303
|
+
// POST exists for the lifecycle settings only: no body = bad request, and the
|
|
304
|
+
// response says what is missing instead of pretending to be read-only.
|
|
305
|
+
const write = await call(state, '/v1/config', { method: 'POST', body: {} })
|
|
306
|
+
assert.equal(write.status, 400)
|
|
307
|
+
assert.match((await write.json()).message, /lifecycle is required/)
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
test('unknown paths are 404, wrong methods are 405', async (t) => {
|
|
311
|
+
const { state } = await startFixture(t)
|
|
312
|
+
const missing = await call(state, '/v1/nope')
|
|
313
|
+
assert.equal(missing.status, 404)
|
|
314
|
+
assert.equal((await missing.json()).code, 'not-found')
|
|
315
|
+
|
|
316
|
+
const wrongMethod = await call(state, '/v1/status?cwd=/tmp/ws', { method: 'POST', body: {} })
|
|
317
|
+
assert.equal(wrongMethod.status, 405)
|
|
318
|
+
|
|
319
|
+
const healthPost = await call(state, '/v1/health', { method: 'POST', token: null, apiVersion: null })
|
|
320
|
+
assert.equal(healthPost.status, 405)
|
|
321
|
+
})
|
|
322
|
+
|
|
323
|
+
test('shutdown answers, then removes the state file', async (t) => {
|
|
324
|
+
const { home, state } = await startFixture(t)
|
|
325
|
+
const response = await call(state, '/v1/shutdown', { method: 'POST', body: { reason: 'test' } })
|
|
326
|
+
assert.equal(response.status, 200)
|
|
327
|
+
assert.equal((await response.json()).draining, true)
|
|
328
|
+
const deadline = Date.now() + 4000
|
|
329
|
+
while (Date.now() < deadline) {
|
|
330
|
+
try {
|
|
331
|
+
const { readRisdState } = await import('../lib/risd/state.js')
|
|
332
|
+
if (readRisdState(home) === null) return
|
|
333
|
+
} catch {
|
|
334
|
+
/* keep waiting */
|
|
335
|
+
}
|
|
336
|
+
await new Promise((resolve) => setTimeout(resolve, 50))
|
|
337
|
+
}
|
|
338
|
+
assert.equal(risdStatePath(home).length > 0, true)
|
|
339
|
+
assert.fail('state file was not removed')
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
test('health names this daemon instance so a stale page notices a restart (review A3-P1-1)', async (t) => {
|
|
343
|
+
// The page embeds the instance at /ui load time. A restart always changes it
|
|
344
|
+
// (new process, new token), which is what lets the page reload itself instead of
|
|
345
|
+
// answering 401 forever; the field must never be the token.
|
|
346
|
+
const home = makeHome('risd-instance-')
|
|
347
|
+
const saved = process.env.DSH_RIS_IDE_PROXY_HOME
|
|
348
|
+
process.env.DSH_RIS_IDE_PROXY_HOME = home
|
|
349
|
+
t.after(() => {
|
|
350
|
+
if (saved === undefined) delete process.env.DSH_RIS_IDE_PROXY_HOME
|
|
351
|
+
else process.env.DSH_RIS_IDE_PROXY_HOME = saved
|
|
352
|
+
removeHome(home)
|
|
353
|
+
})
|
|
354
|
+
const env = { DSH_RIS_IDE_PROXY_HOME: home }
|
|
355
|
+
const first = await startRisdProcess({ home, env })
|
|
356
|
+
const firstBody = await (await call(first.state, '/v1/health', { token: null, apiVersion: null })).json()
|
|
357
|
+
assert.equal(typeof firstBody.instance, 'string')
|
|
358
|
+
assert.equal(firstBody.instance, firstBody.startedAt, 'the instance is the moment this process started')
|
|
359
|
+
assert.equal('token' in firstBody, false, 'health never leaks the token')
|
|
360
|
+
await first.stop()
|
|
361
|
+
const second = await startRisdProcess({ home, env })
|
|
362
|
+
t.after(() => second.stop())
|
|
363
|
+
const secondBody = await (await call(second.state, '/v1/health', { token: null, apiVersion: null })).json()
|
|
364
|
+
assert.notEqual(secondBody.instance, firstBody.instance, 'a restart must invalidate pages embedding the old value')
|
|
365
|
+
})
|
|
366
|
+
|
|
367
|
+
test('/v1/dsh drops unusable `at` values and counts them (review A3-P2-6)', async (t) => {
|
|
368
|
+
const { home, state } = await startFixture(t)
|
|
369
|
+
const now = Date.now()
|
|
370
|
+
const row = (cwd, at) => ({ url: 'http://127.0.0.1:3080', sessionId: `s-${cwd}`, cwd, at })
|
|
371
|
+
writeFileSync(join(home, 'dsh-window.json'), `${JSON.stringify({
|
|
372
|
+
windows: [
|
|
373
|
+
row('/tmp/live', new Date(now).toISOString()),
|
|
374
|
+
row('/tmp/epoch', now), // epoch ms is not what the writer stores
|
|
375
|
+
row('/tmp/future', new Date(now + 60 * 60_000).toISOString()),
|
|
376
|
+
row('/tmp/junk', 'yesterday'),
|
|
377
|
+
],
|
|
378
|
+
})}\n`)
|
|
379
|
+
const body = await (await call(state, '/v1/dsh')).json()
|
|
380
|
+
assert.equal(body.available, true)
|
|
381
|
+
assert.deepEqual(body.windows.map((entry) => entry.cwd), ['/tmp/live'])
|
|
382
|
+
assert.equal(body.dropped, 3, 'every unusable timestamp is reported, not silently pruned')
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
test('a sent row is upserted and a row left out is retired (no source exceptions)', async (t) => {
|
|
386
|
+
const { home, state } = await startFixture(t)
|
|
387
|
+
const view = await (await call(state, `/v1/proxy?cwd=${encodeURIComponent(home)}`)).json()
|
|
388
|
+
const row = { id: 'kept-1', program: 'java', hosts: '10.0.0.*', ports: '*', enabled: true, source: 'yds' }
|
|
389
|
+
const saved = await call(state, '/v1/proxy', {
|
|
390
|
+
method: 'POST',
|
|
391
|
+
body: { cwd: home, config: { socks: view.socks, listenPort: view.listenPort, rules: [row] }, revision: view.revision },
|
|
392
|
+
})
|
|
393
|
+
assert.equal(saved.status, 200)
|
|
394
|
+
const after = await (await call(state, `/v1/proxy?cwd=${encodeURIComponent(home)}`)).json()
|
|
395
|
+
assert.deepEqual(after.rules.map((rule) => rule.id), ['kept-1'])
|
|
396
|
+
})
|
|
397
|
+
|
|
398
|
+
test('an upload whose digest is not the pinned one is rejected (review B-P0-1)', async (t) => {
|
|
399
|
+
const home = makeHome('risd-digest-')
|
|
400
|
+
const savedHome = process.env.DSH_RIS_IDE_PROXY_HOME
|
|
401
|
+
const savedSha = process.env.DSH_RIS_IDE_PROXYBRIDGE_SHA256
|
|
402
|
+
const env = { DSH_RIS_IDE_PROXY_HOME: home, DSH_RIS_IDE_PROXYBRIDGE_SHA256: '0'.repeat(64) }
|
|
403
|
+
process.env.DSH_RIS_IDE_PROXY_HOME = home
|
|
404
|
+
process.env.DSH_RIS_IDE_PROXYBRIDGE_SHA256 = env.DSH_RIS_IDE_PROXYBRIDGE_SHA256
|
|
405
|
+
t.after(() => {
|
|
406
|
+
if (savedHome === undefined) delete process.env.DSH_RIS_IDE_PROXY_HOME
|
|
407
|
+
else process.env.DSH_RIS_IDE_PROXY_HOME = savedHome
|
|
408
|
+
if (savedSha === undefined) delete process.env.DSH_RIS_IDE_PROXYBRIDGE_SHA256
|
|
409
|
+
else process.env.DSH_RIS_IDE_PROXYBRIDGE_SHA256 = savedSha
|
|
410
|
+
removeHome(home)
|
|
411
|
+
})
|
|
412
|
+
const daemon = await startRisdProcess({ home, env })
|
|
413
|
+
t.after(() => daemon.stop())
|
|
414
|
+
const response = await upload(daemon.state, bundleTgz())
|
|
415
|
+
assert.equal(response.status, 400)
|
|
416
|
+
const body = await response.json()
|
|
417
|
+
assert.equal(body.ok, false)
|
|
418
|
+
assert.equal(body.code, 'hash-mismatch')
|
|
419
|
+
assert.equal(body.expected, '0'.repeat(64))
|
|
420
|
+
assert.match(body.actual, /^[0-9a-f]{64}$/)
|
|
421
|
+
// A rejected upload must not leave a half-installed component behind.
|
|
422
|
+
const status = await (await call(daemon.state, '/v1/proxybridge')).json()
|
|
423
|
+
assert.equal(status.installed, false)
|
|
424
|
+
assert.equal(status.verified, false)
|
|
425
|
+
})
|
|
426
|
+
|
|
427
|
+
test('an upload matching the pinned digest installs and verifies (review B-P0-1)', async (t) => {
|
|
428
|
+
const home = makeHome('risd-digest-')
|
|
429
|
+
const tgz = bundleTgz()
|
|
430
|
+
const digest = createHash('sha256').update(tgz).digest('hex')
|
|
431
|
+
const savedHome = process.env.DSH_RIS_IDE_PROXY_HOME
|
|
432
|
+
const savedSha = process.env.DSH_RIS_IDE_PROXYBRIDGE_SHA256
|
|
433
|
+
const env = { DSH_RIS_IDE_PROXY_HOME: home, DSH_RIS_IDE_PROXYBRIDGE_SHA256: digest }
|
|
434
|
+
process.env.DSH_RIS_IDE_PROXY_HOME = home
|
|
435
|
+
process.env.DSH_RIS_IDE_PROXYBRIDGE_SHA256 = digest
|
|
436
|
+
t.after(() => {
|
|
437
|
+
if (savedHome === undefined) delete process.env.DSH_RIS_IDE_PROXY_HOME
|
|
438
|
+
else process.env.DSH_RIS_IDE_PROXY_HOME = savedHome
|
|
439
|
+
if (savedSha === undefined) delete process.env.DSH_RIS_IDE_PROXYBRIDGE_SHA256
|
|
440
|
+
else process.env.DSH_RIS_IDE_PROXYBRIDGE_SHA256 = savedSha
|
|
441
|
+
removeHome(home)
|
|
442
|
+
})
|
|
443
|
+
const daemon = await startRisdProcess({ home, env })
|
|
444
|
+
t.after(() => daemon.stop())
|
|
445
|
+
const response = await upload(daemon.state, tgz)
|
|
446
|
+
assert.equal(response.status, 200)
|
|
447
|
+
const body = await response.json()
|
|
448
|
+
assert.equal(body.ok, true)
|
|
449
|
+
assert.equal(body.installed, true)
|
|
450
|
+
assert.equal(body.sha256, digest)
|
|
451
|
+
const status = await (await call(daemon.state, '/v1/proxybridge')).json()
|
|
452
|
+
assert.equal(status.installed, true)
|
|
453
|
+
assert.equal(status.sha256, digest)
|
|
454
|
+
assert.equal(status.actualSha256, digest)
|
|
455
|
+
assert.equal(status.verified, true)
|
|
456
|
+
})
|
|
457
|
+
|
|
458
|
+
// m11421: the page's 「重启并刷新」 relies on the daemon spawning its own successor.
|
|
459
|
+
// The successor must wait for the predecessor to exit (port + handoff stamp) and the
|
|
460
|
+
// old process must take the handoff path so the engine/bridge survive the restart.
|
|
461
|
+
test('a restart request hands over to a successor that waits for this pid (m11421)', () => {
|
|
462
|
+
const server = readFileSync(new URL('../lib/risd/server.js', import.meta.url), 'utf8')
|
|
463
|
+
assert.match(server, /path === '\/v1\/restart'/, 'the daemon exposes a restart endpoint')
|
|
464
|
+
assert.match(server, /spawnRestartSuccessor\(\)\n\s*if \(onShutdown !== null\) onShutdown\(true\)/, 'the restart path spawns the successor then hands off')
|
|
465
|
+
assert.match(server, /'serve', '--wait-pid', String\(process\.pid\)/, 'the successor waits for the old pid')
|
|
466
|
+
const cli = readFileSync(new URL('../bin/risd.mjs', import.meta.url), 'utf8')
|
|
467
|
+
assert.match(cli, /arg === '--wait-pid'/, 'the CLI understands --wait-pid')
|
|
468
|
+
assert.match(cli, /await waitForPidExit\(options\.waitPid, 20000\)/, 'serve waits before binding the port')
|
|
469
|
+
})
|
|
470
|
+
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One failed daemon request must not demote the plugin to a local writer.
|
|
3
|
+
*
|
|
4
|
+
* Review C-P0-2: the bridge used to null its state AND its lease on the first
|
|
5
|
+
* failure. The daemon then kept owning the table while the plugin wrote it too
|
|
6
|
+
* (split brain), and the lost lease made `followDsh` tear down tunnels other
|
|
7
|
+
* windows were still using. Now the pointer is "degraded", the lease survives,
|
|
8
|
+
* and a write refuses to fall back while the daemon is provably alive.
|
|
9
|
+
*/
|
|
10
|
+
import assert from 'node:assert/strict'
|
|
11
|
+
import { createServer } from 'node:http'
|
|
12
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
13
|
+
import { tmpdir } from 'node:os'
|
|
14
|
+
import { join } from 'node:path'
|
|
15
|
+
import { Readable } from 'node:stream'
|
|
16
|
+
import test from 'node:test'
|
|
17
|
+
|
|
18
|
+
const home = mkdtempSync(join(tmpdir(), 'risd-degrade-'))
|
|
19
|
+
process.env.DSH_RIS_IDE_PROXY_HOME = home
|
|
20
|
+
|
|
21
|
+
const { __test } = await import('../lib/index.js')
|
|
22
|
+
const { RISD_API_VERSION } = await import('../lib/risd/state.js')
|
|
23
|
+
|
|
24
|
+
function fakeRes() {
|
|
25
|
+
return {
|
|
26
|
+
status: 0,
|
|
27
|
+
chunks: [],
|
|
28
|
+
writeHead(status) { this.status = status },
|
|
29
|
+
write(chunk) { this.chunks.push(String(chunk)); return true },
|
|
30
|
+
end(chunk) { if (chunk !== undefined) this.chunks.push(String(chunk)) },
|
|
31
|
+
json() { return JSON.parse(this.chunks.join('')) },
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function fakeReq(method, url, body) {
|
|
35
|
+
const chunks = body === undefined ? [] : [Buffer.from(JSON.stringify(body))]
|
|
36
|
+
const req = Readable.from(chunks)
|
|
37
|
+
req.method = method
|
|
38
|
+
req.url = url
|
|
39
|
+
req.headers = { host: '127.0.0.1:3080', 'content-type': 'application/json' }
|
|
40
|
+
return req
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const workspace = mkdtempSync(join(tmpdir(), 'risd-degrade-ws-'))
|
|
44
|
+
const ctx = { sessions: { get: () => ({ header: { cwd: workspace } }) } }
|
|
45
|
+
|
|
46
|
+
test.after(() => {
|
|
47
|
+
__test.setRisdBridge(null)
|
|
48
|
+
rmSync(home, { recursive: true, force: true })
|
|
49
|
+
rmSync(workspace, { recursive: true, force: true })
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
test('a failed read keeps the lease, marks the bridge degraded and answers locally', async () => {
|
|
53
|
+
const bridge = {
|
|
54
|
+
mode: 'auto',
|
|
55
|
+
state: { url: 'http://127.0.0.1:9', token: 'x', apiVersion: RISD_API_VERSION, port: 9 },
|
|
56
|
+
leaseId: 'lease-x',
|
|
57
|
+
pending: null,
|
|
58
|
+
warnedAt: 0,
|
|
59
|
+
degraded: false,
|
|
60
|
+
lastProbeAt: Date.now(),
|
|
61
|
+
}
|
|
62
|
+
__test.setRisdBridge(bridge)
|
|
63
|
+
const res = fakeRes()
|
|
64
|
+
await __test.serveProxy(ctx, fakeReq('GET', '/dsh-ris-ide/proxy?sessionId=s1'), res)
|
|
65
|
+
assert.equal(res.status, 200, 'the dialog still works when the daemon is unreachable')
|
|
66
|
+
assert.equal(bridge.state, null)
|
|
67
|
+
assert.equal(bridge.degraded, true)
|
|
68
|
+
assert.equal(bridge.leaseId, 'lease-x', 'the lease must survive a single failure')
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
test('a write refuses to go local while the daemon still answers health', async () => {
|
|
72
|
+
const table = { socks: { host: 'proxy.example.com', port: 10080 }, listenPort: 11081, rules: [], shadows: [] }
|
|
73
|
+
writeFileSync(join(home, 'proxy.json'), `${JSON.stringify(table, null, 2)}\n`, { mode: 0o600 })
|
|
74
|
+
const server = createServer((req, res) => {
|
|
75
|
+
if (req.url === '/v1/health') {
|
|
76
|
+
res.writeHead(200, { 'content-type': 'application/json' })
|
|
77
|
+
res.end(JSON.stringify({ ok: true, apiVersion: RISD_API_VERSION, pid: 123, port: server.address().port, version: '1.8.0' }))
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
res.writeHead(404).end()
|
|
81
|
+
})
|
|
82
|
+
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve))
|
|
83
|
+
const port = server.address().port
|
|
84
|
+
writeFileSync(join(home, 'risd.json'), `${JSON.stringify({
|
|
85
|
+
ok: true, apiVersion: RISD_API_VERSION, pid: 123, port, token: 'token-x',
|
|
86
|
+
version: '1.8.0', startedAt: new Date().toISOString(), home,
|
|
87
|
+
url: `http://127.0.0.1:${port}`,
|
|
88
|
+
}, null, 2)}\n`, { mode: 0o600 })
|
|
89
|
+
const bridge = { mode: 'auto', state: null, leaseId: 'lease-x', pending: null, warnedAt: 0, degraded: true, lastProbeAt: Date.now() }
|
|
90
|
+
__test.setRisdBridge(bridge)
|
|
91
|
+
const before = readFileSync(join(home, 'proxy.json'), 'utf8')
|
|
92
|
+
const res = fakeRes()
|
|
93
|
+
await __test.serveProxy(ctx, fakeReq('POST', '/dsh-ris-ide/proxy', {
|
|
94
|
+
sessionId: 's1',
|
|
95
|
+
revision: '',
|
|
96
|
+
config: { socks: table.socks, listenPort: table.listenPort, rules: [] },
|
|
97
|
+
}), res)
|
|
98
|
+
assert.equal(res.status, 503, 'writing behind a live daemon is refused, not silently local')
|
|
99
|
+
assert.equal(readFileSync(join(home, 'proxy.json'), 'utf8'), before, 'the machine table is untouched')
|
|
100
|
+
await new Promise((resolve) => server.close(resolve))
|
|
101
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// The maintenance page's build stamp: "which daemon code is this process running,
|
|
2
|
+
// and what would a restart load?". It is computed from file metadata only — never
|
|
3
|
+
// contents — and cached briefly because /v1/health is polled (review A3-P2-9).
|
|
4
|
+
import assert from 'node:assert/strict'
|
|
5
|
+
import test from 'node:test'
|
|
6
|
+
|
|
7
|
+
import { BUILD_STAMP_TTL_MS, UI_SOURCE_FILES, __test, buildStamp } from '../lib/risd/build.js'
|
|
8
|
+
|
|
9
|
+
test('buildStamp is stable metadata and a short cache does not change it (review A3-P2-9)', () => {
|
|
10
|
+
const first = buildStamp()
|
|
11
|
+
assert.match(first, /^[0-9a-f]{12}$/, 'twelve hex chars identify the daemon code')
|
|
12
|
+
assert.equal(buildStamp(), first, 'the cache returns the same stamp for unchanged files')
|
|
13
|
+
assert.equal(BUILD_STAMP_TTL_MS, 5000, 'health may lag up to five seconds, not minutes')
|
|
14
|
+
assert.ok(UI_SOURCE_FILES.length >= 10, 'the stamp covers the modules the page renders')
|
|
15
|
+
|
|
16
|
+
// A forced recompute over unchanged files must agree: the stamp is a function of
|
|
17
|
+
// size+mtime, not of how many times it was asked.
|
|
18
|
+
__test.resetBuildStampCache()
|
|
19
|
+
assert.equal(buildStamp(), first)
|
|
20
|
+
})
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `risd serve` without `--home` must use the machine home, not `<cwd>/undefined`.
|
|
3
|
+
*
|
|
4
|
+
* Node coerces an assignment of `undefined` to `process.env.X` into the STRING
|
|
5
|
+
* "undefined"; the CLI used to do that before resolving the default, so every
|
|
6
|
+
* machine-level file (risd.json, token, heartbeat, git state) landed under
|
|
7
|
+
* `<cwd>/undefined/`. The plugin then never found the daemon, the port stayed
|
|
8
|
+
* taken by a ghost and `risd stop` could not reach it (review A-P0-1).
|
|
9
|
+
*/
|
|
10
|
+
import assert from 'node:assert/strict'
|
|
11
|
+
import { existsSync, mkdtempSync, rmSync } from 'node:fs'
|
|
12
|
+
import { tmpdir } from 'node:os'
|
|
13
|
+
import { join } from 'node:path'
|
|
14
|
+
import { spawn } from 'node:child_process'
|
|
15
|
+
import test from 'node:test'
|
|
16
|
+
import { readRisdState } from '../lib/risd/state.js'
|
|
17
|
+
|
|
18
|
+
const CLI = new URL('../bin/risd.mjs', import.meta.url).pathname
|
|
19
|
+
|
|
20
|
+
test('a CLI run without --home resolves the machine home from the environment', async (t) => {
|
|
21
|
+
const home = mkdtempSync(join(tmpdir(), 'risd-cli-home-'))
|
|
22
|
+
const cwd = mkdtempSync(join(tmpdir(), 'risd-cli-cwd-'))
|
|
23
|
+
const child = spawn(process.execPath, [CLI, 'serve'], {
|
|
24
|
+
cwd,
|
|
25
|
+
env: Object.assign({}, process.env, { DSH_RIS_IDE_PROXY_HOME: home, DSH_RISD_PORT: '0' }),
|
|
26
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
27
|
+
})
|
|
28
|
+
t.after(() => {
|
|
29
|
+
child.kill('SIGTERM')
|
|
30
|
+
rmSync(home, { recursive: true, force: true })
|
|
31
|
+
rmSync(cwd, { recursive: true, force: true })
|
|
32
|
+
})
|
|
33
|
+
let stderr = ''
|
|
34
|
+
child.stderr.setEncoding('utf8')
|
|
35
|
+
child.stderr.on('data', (chunk) => { stderr += chunk })
|
|
36
|
+
const started = await new Promise((resolve) => {
|
|
37
|
+
const timer = setInterval(() => {
|
|
38
|
+
const state = readRisdState(home)
|
|
39
|
+
if (state !== null) { clearInterval(timer); resolve(state) }
|
|
40
|
+
}, 100)
|
|
41
|
+
timer.unref()
|
|
42
|
+
child.once('exit', () => { clearInterval(timer); resolve(null) })
|
|
43
|
+
setTimeout(() => { clearInterval(timer); resolve(null) }, 8000).unref()
|
|
44
|
+
})
|
|
45
|
+
assert.notEqual(started, null, `risd serve did not start: ${stderr}`)
|
|
46
|
+
assert.equal(started.home, home)
|
|
47
|
+
// The regression: the state was written under the cwd because the env var
|
|
48
|
+
// became the literal string "undefined".
|
|
49
|
+
assert.equal(existsSync(join(cwd, 'undefined')), false)
|
|
50
|
+
})
|