Skip to content

Commit

Permalink
add timeout on demo script (#38)
Browse files Browse the repository at this point in the history
* add timeout on demo script

* Update demo.ts
  • Loading branch information
Rithwik0480 authored Sep 14, 2023
1 parent d018157 commit 36396f7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ function getChallenge(): string {
return Cord.Utils.UUID.generate()
}

const timeoutId = setTimeout(() => {
console.log("\nTime out. Bye! ⏰ ⏰ ⏰ ")
Cord.disconnect()
process.exit(1)
}, 120000)

async function main() {

const networkAddress = NETWORK_ADDRESS ?? 'wss://sparknet.cord.network'
Expand Down Expand Up @@ -307,9 +313,11 @@ async function main() {
} else {
console.log('✅ Verification failed! 🚫')
}

}

main()
.then(() => console.log('\nBye! 👋 👋 👋 '))
.then(() => {console.log('\nBye! 👋 👋 👋 '),clearTimeout(timeoutId)})
.finally(Cord.disconnect)

process.on('SIGINT', async () => {
Expand Down

0 comments on commit 36396f7

Please sign in to comment.