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

UnhandledPromiseRejectionWarning when sending message #24

Open
yunyu opened this issue Mar 7, 2018 · 2 comments
Open

UnhandledPromiseRejectionWarning when sending message #24

yunyu opened this issue Mar 7, 2018 · 2 comments

Comments

@yunyu
Copy link

yunyu commented Mar 7, 2018

When running this script:

const iMessage = require('osa-imessage');
iMessage.send('number redacted', 'Hello World');

I get this output in the terminal:

This version of macOS (10.11.6) is currently untested with this version of osa-imessage. Proceed with caution.
(node:644) UnhandledPromiseRejectionWarning: Error: Command failed: /usr/bin/osascript -l JavaScript
31:73: syntax error: Error on line 3: SyntaxError: Unexpected token '>' (-2700)

    at ChildProcess.exithandler (child_process.js:275:12)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:567:12)
(node:644) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:644) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code

I am running Node v8.9.4 and OS X 10.11.6.

@yunyu
Copy link
Author

yunyu commented Mar 7, 2018

To me, this looks like https://github.com/wtfaremyinitials/osa2/blob/master/index.js#L6 outputting ES6, which is presumably not supported by osascript. It looks like changing all the arrow functions to function () (and possibly changing all of the osa() functions to ES5) would fix it.

Alternatively, using the Babel API in osa2 would also fix it: yunyu/osa2@38bdc2c

@wtfaremyinitials
Copy link
Owner

The module works as-is on macOS 10.13, so I guess ES6 was added to osascript recently. I like the babel solution; if you PR it I'd be more than happy to merge it.

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

2 participants