MCPcopy Create free account
hub / github.com/cloudflare/computer / setExit

Method setExit

packages/computerd/src/exec/log.ts:130–157  ·  view source on GitHub ↗
(code: number)

Source from the content-addressed store, hash-verified

128 }
129
130 setExit(code: number): number {
131 const meta = this.meta();
132 if (meta === undefined) throw new Error(`log ${this.id}: setExit after dispose`);
133 if (meta.exited_at !== null) throw new Error(`log ${this.id}: double exit`);
134 const seq = this.nextSeq++;
135 const ts = this.opts.now();
136 this.db.transactionSync(() => {
137 if (meta.evicted === 0) {
138 const buf = Buffer.alloc(4);
139 buf.writeInt32LE(code, 0);
140 this.db.run(
141 `INSERT INTO computerd_exec_log (exec_id, seq, ts, kind, value) VALUES (?, ?, ?, ?, ?)`,
142 this.id,
143 seq,
144 ts,
145 KIND_EXIT,
146 new Uint8Array(buf),
147 );
148 }
149 this.db.run(
150 `UPDATE computerd_exec_meta SET exited_at = ?, exit_code = ? WHERE exec_id = ?`,
151 ts,
152 code,
153 this.id,
154 );
155 });
156 return seq;
157 }
158
159 // Drop every row for this id, both log and meta. Used on
160 // disposeExec() and on Runner shutdown. After this returns,

Callers 2

finaliseMethod · 0.80
spawnFailedMethod · 0.80

Calls 3

metaMethod · 0.95
transactionSyncMethod · 0.65
runMethod · 0.45

Tested by

no test coverage detected