“Cannot switch to old mode now” - Node.JS apn module error in tls.connect function

前端 未结 2 1814
被撕碎了的回忆
被撕碎了的回忆 2021-01-04 11:26

I am trying to implement Node.JS apn module to connect to APNS (Apple Push Notification service) to push notification to iPhone devices from the Node server (using ExpressJS

相关标签:
2条回答
  • 2021-01-04 12:00

    Not sure if this is the 'correct' way to fix the issue, but it worked for me. (You'll need to have brew)

    1. brew uninstall node
    2. brew install nvm
    3. copy this into your shell config (in my case .zshrc)

    export NVM_DIR=~/.nvm source $(brew --prefix nvm)/nvm.sh

    1. nvm install iojs
    0 讨论(0)
  • 2021-01-04 12:07

    Update: The behavior described below may have changed since this answer was originally written; as of 0.12.3, the docs suggest that you can now switch back and forth between paused (new) and flowing (old) mode, and that streams start out in paused mode.
    Also, "old" mistakenly suggests a deprecated way of doing things, but while the flowing mode came first, both are supported and have their uses.


    I don't have a specific answer, but a general explanation:

    The short of it: old code that calls .resume() or .pause() on readable streams can break on node 0.10 and higher.

    The long of it: You see this error on node 0.10 or higher when a readable stream has been initialized to use the new, paused mode (based on the readable event) and an attempt is later made to switch to the old, flowing mode (based on the data event), which is implicitly attempted when you call .resume() or .pause() - see the docs.

    Setting up a readable event may not even be directly involved. For instance, it seems that using the .pipe() method now implicitly switches to the new, paused mode, so a subsequent .resume() call would trigger this error.

    0 讨论(0)
提交回复
热议问题