Pronouns labels on Bluesky

clear interval when disconnecting from the firehose

Changed files
+6 -1
src
+6 -1
src/main.ts
···
const subscribe = async () => {
let cursorFirehose = 0;
+
let intervalID: NodeJS.Timeout;
const cursorFile = fs.readFileSync("cursor.txt", "utf8");
const firehose = new Firehose({ cursor: cursorFile ?? "" });
···
});
firehose.on("open", () => {
-
setInterval(() => {
+
intervalID = setInterval(() => {
const timestamp = new Date().toISOString();
console.log(`${timestamp} cursor: ${cursorFirehose}`);
fs.writeFile("cursor.txt", cursorFirehose.toString(), (err) => {
if (err) console.error(err);
});
}, 60000);
+
});
+
+
firehose.on("close", () => {
+
clearInterval(intervalID);
});
firehose.on("commit", async (commit) => {