Coder Social home page Coder Social logo

Comments (10)

AlCalzone avatar AlCalzone commented on August 26, 2024

This can happen on any request/observation that has not completed yet when the user calls reset(). It's not a critical error but has to be there to notify the user that his request cannot be completed.

from node-tradfri-client.

neophob avatar neophob commented on August 26, 2024

for reference, this error I captured:

Error: CoapClient was reset
    at normalizeReason (/myproject/node_modules/node-coap-client/build/lib/DeferredPromise.js:5:16)
    at Promise.rej [as reject] (/myproject/node_modules/node-coap-client/build/lib/DeferredPromise.js:13:36)
    at Function.reset (/myproject/node_modules/node-coap-client/build/CoapClient.js:191:33)
    at TradfriClient.reset (/myproject/node_modules/node-tradfri-client/build/tradfri-client.js:158:39)
    at tradfriClient.ping.catch.then (/myproject/app/lib/tradfriService.js:167:32)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

To reproduce:

  • make sure you can control your lights
  • disconnect ethernet not tradfri gateway
  • send 10 commands (for example turnOn) to the gateway
  • wait a minute, then the error pops up

from node-tradfri-client.

neophob avatar neophob commented on August 26, 2024

Another option would capture this rejected promise and use the error callback to signal an error

from node-tradfri-client.

AlCalzone avatar AlCalzone commented on August 26, 2024

The error pops up, because you call reset in your app:

at TradfriClient.reset (/myproject/node_modules/node-tradfri-client/build/tradfri-client.js:158:39)
at tradfriClient.ping.catch.then (/myproject/app/lib/tradfriService.js:167:32)

from node-tradfri-client.

neophob avatar neophob commented on August 26, 2024

I know, it was just an idea, either update the docs that reset is an async function that returns a promise OR don't change the docs but use the error callback to signal the error.

from node-tradfri-client.

AlCalzone avatar AlCalzone commented on August 26, 2024

I'm leaning towards emitting a general library error and swallow the rejections. This means the corresponding documentation will have to state that all pending promises will neither be resolved or rejected anymore. Do you think this is good from a user's point of view?

Regarding your code snippet:
Are you catching rejections from ping? IMO that should always resolve and never reject. Or am I misunderstanding your stack frame?

from node-tradfri-client.

neophob avatar neophob commented on August 26, 2024

I'm fine with swallowing the error and emitting an error - i think as long as the emitted error is understandable it should be fine and makes the implementation easier.

Yes I catch ping call, there was a rejection when I rebooted the gateway.

from node-tradfri-client.

AlCalzone avatar AlCalzone commented on August 26, 2024

Yes I catch ping call, there was a rejection when I rebooted the gateway.

DTLS timeout? If so, that's a bug since ping should handle the errors itself.

from node-tradfri-client.

AlCalzone avatar AlCalzone commented on August 26, 2024

"CoapClient was reset" should now be swallowed and transformed into an "error" event with a slightly more descriptive message.

from node-tradfri-client.

AlCalzone avatar AlCalzone commented on August 26, 2024

Released in v0.10.0

from node-tradfri-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.