opensteer 0.4.3 → 0.4.4

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.
@@ -9746,6 +9746,19 @@ function getCommandHandler(name) {
9746
9746
  // src/cli/server.ts
9747
9747
  var instance = null;
9748
9748
  var launchPromise = null;
9749
+ function invalidateInstance() {
9750
+ if (!instance) return;
9751
+ instance.close().catch(() => {
9752
+ });
9753
+ instance = null;
9754
+ }
9755
+ function attachLifecycleListeners(inst) {
9756
+ try {
9757
+ inst.page.on("close", invalidateInstance);
9758
+ inst.context.on("close", invalidateInstance);
9759
+ } catch {
9760
+ }
9761
+ }
9749
9762
  var namespace = process.env.OPENSTEER_NAME?.trim();
9750
9763
  if (!namespace) {
9751
9764
  process.stderr.write("Missing OPENSTEER_NAME environment variable.\n");
@@ -9780,16 +9793,11 @@ async function handleRequest(request, socket) {
9780
9793
  const profileDir = args["profile-dir"];
9781
9794
  if (instance && !launchPromise) {
9782
9795
  try {
9783
- const alive = !instance.page.isClosed();
9784
- if (!alive) {
9785
- await instance.close().catch(() => {
9786
- });
9787
- instance = null;
9796
+ if (instance.page.isClosed()) {
9797
+ invalidateInstance();
9788
9798
  }
9789
9799
  } catch {
9790
- await instance?.close().catch(() => {
9791
- });
9792
- instance = null;
9800
+ invalidateInstance();
9793
9801
  }
9794
9802
  }
9795
9803
  if (!instance) {
@@ -9808,6 +9816,7 @@ async function handleRequest(request, socket) {
9808
9816
  });
9809
9817
  try {
9810
9818
  await launchPromise;
9819
+ attachLifecycleListeners(instance);
9811
9820
  } catch (err) {
9812
9821
  instance = null;
9813
9822
  throw err;
@@ -255,6 +255,19 @@ function getCommandHandler(name) {
255
255
  // src/cli/server.ts
256
256
  var instance = null;
257
257
  var launchPromise = null;
258
+ function invalidateInstance() {
259
+ if (!instance) return;
260
+ instance.close().catch(() => {
261
+ });
262
+ instance = null;
263
+ }
264
+ function attachLifecycleListeners(inst) {
265
+ try {
266
+ inst.page.on("close", invalidateInstance);
267
+ inst.context.on("close", invalidateInstance);
268
+ } catch {
269
+ }
270
+ }
258
271
  var namespace = process.env.OPENSTEER_NAME?.trim();
259
272
  if (!namespace) {
260
273
  process.stderr.write("Missing OPENSTEER_NAME environment variable.\n");
@@ -289,16 +302,11 @@ async function handleRequest(request, socket) {
289
302
  const profileDir = args["profile-dir"];
290
303
  if (instance && !launchPromise) {
291
304
  try {
292
- const alive = !instance.page.isClosed();
293
- if (!alive) {
294
- await instance.close().catch(() => {
295
- });
296
- instance = null;
305
+ if (instance.page.isClosed()) {
306
+ invalidateInstance();
297
307
  }
298
308
  } catch {
299
- await instance?.close().catch(() => {
300
- });
301
- instance = null;
309
+ invalidateInstance();
302
310
  }
303
311
  }
304
312
  if (!instance) {
@@ -317,6 +325,7 @@ async function handleRequest(request, socket) {
317
325
  });
318
326
  try {
319
327
  await launchPromise;
328
+ attachLifecycleListeners(instance);
320
329
  } catch (err) {
321
330
  instance = null;
322
331
  throw err;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opensteer",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "packageManager": "pnpm@10.29.3",
5
5
  "description": "Open-source browser automation SDK with robust selectors and deterministic replay.",
6
6
  "license": "MIT",