Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network printer - error when calling close #6

Open
JaydeeSale opened this issue Mar 12, 2018 · 0 comments
Open

Network printer - error when calling close #6

JaydeeSale opened this issue Mar 12, 2018 · 0 comments

Comments

@JaydeeSale
Copy link

this.device.on("close", () => {
this.connected = false;

           if (this.retrying && (retries === 0 || this.retries < retries)) {
            this.retries++;
            setTimeout(() => {
                this.device.connect(this.options.port, this.options.address);
            }, 5000);
        }
        else { //this line will always hit and throw exception on close.
            this.retrying = false;
            throw new Error(`Cannot connect to ${this.options.address}:${this.options.port}`);
        }
    });

when calling close on the printer object the network adapter throws the exception, causing the awaiter to fail, trying to catch the exception has proven tough, causing node to crash. simple fix is to return upon retrying === false, and only throw the exception when it is in a retrying state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant