appium-ios-tuntap 0.1.4 → 0.1.5

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [0.1.5](https://github.com/appium/appium-ios-tuntap/compare/v0.1.4...v0.1.5) (2026-04-09)
2
+
3
+ ### Code Refactoring
4
+
5
+ * remove global signal handlers from library code ([6e267df](https://github.com/appium/appium-ios-tuntap/commit/6e267dffe1785acfcd57d431090e4cd4995bfa39))
6
+
1
7
  ## [0.1.4](https://github.com/appium/appium-ios-tuntap/compare/v0.1.3...v0.1.4) (2026-04-08)
2
8
 
3
9
  ### Bug Fixes
Binary file
package/build/config.gypi CHANGED
@@ -502,7 +502,7 @@
502
502
  "cache": "/Users/runner/.npm",
503
503
  "node_gyp": "/Users/runner/work/appium-ios-tuntap/appium-ios-tuntap/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",
504
504
  "npm_version": "11.11.0",
505
- "userconfig": "/private/var/folders/tb/y368xp_x10s3ty1b_mtl5mxr0000gn/T/2da411b2b99c0b3a7cfaf49f9d25047d/.npmrc",
505
+ "userconfig": "/private/var/folders/tb/y368xp_x10s3ty1b_mtl5mxr0000gn/T/d5aab3f73716915039a0303184de39d0/.npmrc",
506
506
  "init_module": "/Users/runner/.npm-init.js",
507
507
  "globalconfig": "/Users/runner/hostedtoolcache/node/24.14.1/arm64/etc/npmrc",
508
508
  "local_prefix": "/Users/runner/work/appium-ios-tuntap/appium-ios-tuntap",
package/lib/TunTap.d.ts CHANGED
@@ -15,7 +15,7 @@ export declare class TunTap {
15
15
  private device;
16
16
  private isOpen;
17
17
  private isClosed;
18
- private cleanupHandlers;
18
+ private removeExitListener;
19
19
  constructor(name?: string);
20
20
  open(): boolean;
21
21
  close(): boolean;
package/lib/TunTap.js CHANGED
@@ -58,7 +58,7 @@ export class TunTap {
58
58
  device;
59
59
  isOpen;
60
60
  isClosed;
61
- cleanupHandlers = [];
61
+ removeExitListener = null;
62
62
  constructor(name = '') {
63
63
  this.device = new nativeTuntap.TunDevice(name);
64
64
  this.isOpen = false;
@@ -75,13 +75,9 @@ export class TunTap {
75
75
  }
76
76
  };
77
77
  process.once('exit', cleanup);
78
- process.once('SIGINT', cleanup);
79
- process.once('SIGTERM', cleanup);
80
- this.cleanupHandlers.push(() => {
78
+ this.removeExitListener = () => {
81
79
  process.removeListener('exit', cleanup);
82
- process.removeListener('SIGINT', cleanup);
83
- process.removeListener('SIGTERM', cleanup);
84
- });
80
+ };
85
81
  }
86
82
  open() {
87
83
  if (this.isClosed) {
@@ -108,6 +104,10 @@ export class TunTap {
108
104
  return this.isOpen;
109
105
  }
110
106
  close() {
107
+ if (this.removeExitListener) {
108
+ this.removeExitListener();
109
+ this.removeExitListener = null;
110
+ }
111
111
  if (!this.isClosed) {
112
112
  try {
113
113
  if (this.isOpen) {
@@ -115,9 +115,6 @@ export class TunTap {
115
115
  this.isOpen = false;
116
116
  }
117
117
  this.isClosed = true;
118
- // Run cleanup handlers
119
- this.cleanupHandlers.forEach((handler) => handler());
120
- this.cleanupHandlers = [];
121
118
  }
122
119
  catch (err) {
123
120
  throw new TunTapError(`Failed to close device: ${err.message}`);
package/lib/tunnel.js CHANGED
@@ -2,44 +2,6 @@ import { log } from './logger.js';
2
2
  import { TunTap } from './TunTap.js';
3
3
  import { EventEmitter } from 'node:events';
4
4
  import { Buffer } from 'node:buffer';
5
- // Global registry for active tunnel managers
6
- const activeTunnelManagers = new Set();
7
- // Setup process signal handlers
8
- let signalHandlersSetup = false;
9
- function setupSignalHandlers() {
10
- if (signalHandlersSetup) {
11
- return;
12
- }
13
- signalHandlersSetup = true;
14
- const gracefulShutdown = async (signal) => {
15
- log.debug(`Received ${signal}, initiating graceful shutdown...`);
16
- // Copy the set to avoid modification during iteration
17
- const managers = Array.from(activeTunnelManagers);
18
- // Stop all tunnel managers
19
- await Promise.all(managers.map((manager) => {
20
- try {
21
- return manager.stop();
22
- }
23
- catch (err) {
24
- log.error('Error stopping tunnel manager:', err);
25
- }
26
- }));
27
- log.debug('All tunnel managers stopped, exiting...');
28
- process.exit(0);
29
- };
30
- process.on('SIGINT', () => gracefulShutdown('SIGINT'));
31
- process.on('SIGTERM', () => gracefulShutdown('SIGTERM'));
32
- // Handle uncaught exceptions
33
- process.on('uncaughtException', async (err) => {
34
- log.error('Uncaught exception:', err);
35
- await gracefulShutdown('uncaughtException');
36
- process.exit(1);
37
- });
38
- // Handle unhandled promise rejections
39
- process.on('unhandledRejection', (reason, promise) => {
40
- log.error(`Unhandled rejection at: ${promise} reason: ${reason}`);
41
- });
42
- }
43
5
  export class TunnelManager extends EventEmitter {
44
6
  tun;
45
7
  cancelled;
@@ -59,10 +21,6 @@ export class TunnelManager extends EventEmitter {
59
21
  this.packetQueue = [];
60
22
  this.deviceConn = null;
61
23
  this.cleanupPromise = null;
62
- // Setup signal handlers on first tunnel manager creation
63
- setupSignalHandlers();
64
- // Register this manager
65
- activeTunnelManagers.add(this);
66
24
  }
67
25
  addPacketConsumer(consumer) {
68
26
  this.packetConsumers.add(consumer);
@@ -364,8 +322,6 @@ export class TunnelManager extends EventEmitter {
364
322
  }
365
323
  this.tun = null;
366
324
  }
367
- // Unregister from active managers
368
- activeTunnelManagers.delete(this);
369
325
  log.debug(`Tunnel for ${tunName} closed successfully`);
370
326
  }
371
327
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-ios-tuntap",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Native TUN/TAP interface module for Node.js",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",