Closed gabrielcipriano closed 1 month ago
An event emitter loop is preventing PushReceiver instances to be gracefully destroyed
const receiver = new PushReceiver({ debug: true, firebase: firebaseConfig, heartbeatIntervalMs: 500, // a short heartbeat interval persistentIds: [], }); await receiver.connect(); await new Promise<void>(resolve => receiver.onReady(resolve)); receiver.on("ON_CONNECT", () => console.log("Connected")); receiver.on("ON_DISCONNECT", () => console.log("Disconnected")); const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)); await sleep(1_000); // some heartbeats receiver.destroy(); await sleep(10_000); // asleep logs: Disconnected connect Connected Got data: 1 waitForData state: 0 Waiting for 2 more bytes. Got 1 Got data: 65 waitForData state: 0 Processing MCS data: state == 0 VERSION IS 41 RECEIVED PROTO OF TYPE 3 Proto size: 63 waitForData state: 3 Processing MCS data: state == 3 GCM Handshake complete. waitForData state: 1 Waiting for 2 more bytes. Got 0 Got data: 12 ...
Yes I'll remove all socket listeners before destroy
EDIT: Just released 4.1.6
An event emitter loop is preventing PushReceiver instances to be gracefully destroyed
reproduction steps