cowin-pinger icon indicating copy to clipboard operation
cowin-pinger copied to clipboard

UnhandledPromiseRejection

Open cosmicparadox11 opened this issue 3 years ago • 10 comments

UnhandledPromiseRejectionWarning: Error: Command failed: powershell -c Add-Type -AssemblyName presentationCore; $player = New-Object system.windows.media.mediaplayer; $player.open('/home/sampath/.npm/_npx/1034/lib/node_modules/cowin-pinger/sounds/beep.mp3'); $player.Volume = 0.5; $player.Play(); Start-Sleep 1; Start-Sleep -s $player.NaturalDuration.TimeSpan.TotalSeconds;Exit; /bin/sh: 1: Syntax error: word unexpected (expecting ")")

at ChildProcess.exithandler (child_process.js:308:12)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1048:16)
at Socket.<anonymous> (internal/child_process.js:439:11)
at Socket.emit (events.js:315:20)
at Pipe.<anonymous> (net.js:673:12)

cosmicparadox11 avatar May 11 '21 11:05 cosmicparadox11

This seems to be an error related to playing the notification sound when a slot is found. Can you trying running the script from Command Prompt instead of Powershell just to see if that's the cause of the issue.

abhinavdc avatar May 11 '21 12:05 abhinavdc

i am running it on an ubuntu terminal

cosmicparadox11 avatar May 11 '21 12:05 cosmicparadox11

Have you changed any code related to sound notification ? You could for the time being comment out the lines which play the notification sound and this should work.

abhinavdc avatar May 11 '21 13:05 abhinavdc

i haven't made any changes

cosmicparadox11 avatar May 11 '21 13:05 cosmicparadox11

Are you still getting this error, I kept this issue open to see if any other users face this same issue.

I have released new versions of the library so you could try running the latest versions and see if it fixes the issue you had.

abhinavdc avatar May 17 '21 14:05 abhinavdc

still getting the same error

cosmicparadox11 avatar May 17 '21 16:05 cosmicparadox11

This error is in the latest version too.

Stopping Pinger... (node:16758) UnhandledPromiseRejectionWarning: Error: Command failed: powershell -c Add-Type -AssemblyName presentationCore; $player = New-Object system.windows.media.mediaplayer; $player.open('/home/bhartendu/.npm/_npx/16758/lib/node_modules/cowin-pinger/sounds/beep.wav'); $player.Volume = 0.5; $player.Play(); Start-Sleep 1; Start-Sleep -s $player.NaturalDuration.TimeSpan.TotalSeconds;Exit; /bin/sh: 1: Syntax error: word unexpected (expecting ")")

at ChildProcess.exithandler (child_process.js:294:12)
at ChildProcess.emit (events.js:189:13)
at maybeClose (internal/child_process.js:970:16)
at Socket.stream.socket.on (internal/child_process.js:389:11)
at Socket.emit (events.js:189:13)
at Pipe._handle.close (net.js:600:12)

(node:16758) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch

Bhartendu-Kumar avatar May 29 '21 09:05 Bhartendu-Kumar

Can you clone the code and comment out these lines in the code

const sound = require("sound-play");
const path = require("path");
const notificationSound = path.join(__dirname, "sounds/beep.wav");

sound.play(notificationSound);

sound.play(notificationSound, 1);

Now try running npm i and then node app.js run --age=...

abhinavdc avatar May 29 '21 19:05 abhinavdc

The issue is happening because sound-play doesn't support Ubuntu / Linux-based OS.

image

joseph9991 avatar Jul 08 '21 15:07 joseph9991

@abhinavdc I checked out node-wav-player. It is working fine on Ubuntu and Windows. Need to test it with macOS.

If you think it is worth upgrading, then I can work out the changes. Let me know!!

Usage: const sound = require('node-wav-player'); sound.play({path: 'notificationSound'});

joseph9991 avatar Jul 08 '21 19:07 joseph9991