Export singelton class and use it in frontend and backend

hello everyone, could someone guide me why the event is not emitted correctly to the frontend ?

// public/ signals.js
const EventEmitter = require(‘events’);

export class SignalEmitter {
constructor() {
if (!SignalEmitter.instance) {
this.eventEmitter = new EventEmitter();
SignalEmitter.instance = this;
}
return SignalEmitter.instance;
}

registerListenerForJobCount(callback) {
    try {
        console.log("Registering job count event listener");
        this.eventEmitter.once('JobSearchCountReady', (data) => {
            console.log("Data received from event:", data);
            if (callback) {
                callback(data); // Call the provided callback with the data
            }
        });
    } catch (error) {
        console.log("Error in registerListenerForJobCount: ", error);
    }
}

emitJobCount(jobCount) {
    try {
        this.eventEmitter.emit('JobSearchCountReady', jobCount);
        console.log("Emitting job count event to frontend with job count:", jobCount);

    } catch (error) {
        console.log("Error in emitJobCount: ", error);
    }
}

}

SignalEmitter.instance = null;

export function getInstance()
{
return new SignalEmitter();
}

// frontend
export async function myCallback(data) {
console.log(“Job count event received with data:”, data);
}

$w.onReady( function () {
const signalEmitter = getInstance();
signalEmitter.registerListenerForJobCount(myCallback);

// backend
import { SignalEmitter, getInstance } from ‘public/signals’;

export function emit(job) {
const signalEmitter = getInstance();
signalEmitter.emitJobCount(job);
}