abhinavdc / cowin-pinger

Get notified on your phone when there is a vaccine slot available at your location, by running a script on your computer. Uses Cowin portal's public API.
105 stars 45 forks source link

UnhandledPromiseRejection #8

Open cosmicparadox11 opened 3 years ago

cosmicparadox11 commented 3 years ago

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)
abhinavdc commented 3 years ago

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.

cosmicparadox11 commented 3 years ago

i am running it on an ubuntu terminal

abhinavdc commented 3 years ago

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.

cosmicparadox11 commented 3 years ago

i haven't made any changes

abhinavdc commented 3 years ago

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.

cosmicparadox11 commented 3 years ago

still getting the same error

Bhartendu-Kumar commented 3 years ago

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

abhinavdc commented 3 years ago

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=...

joseph9991 commented 3 years ago

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

image

joseph9991 commented 3 years ago

@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'});