JMvelasco
JMvelasco12mo ago

Deno Deploy failed:Uncaught Exception /Permission Denied : Deno.exit() is not allowed

I have a college assignments that needs to be deployed using deno deploy but i get this message when i try to deploy it, my code works fine locally.
No description
5 Replies
marvinh.
marvinh.12mo ago
The Deno.exit() function is not available on Deno Deploy. It doesn't really make sense in a serverless platform where you spin a function up and it terminates when it is done The function/process will automatically exit once all work is completed.
JMvelasco
JMvelasco12mo ago
this the bit of code where i use deno.exit, if i remove it MONGO_URL will give an error
No description
JMvelasco
JMvelasco12mo ago
yesterday late in the night i was going insane trying to make the deploy and tried it today too but cant get it to work
marvinh.
marvinh.12mo ago
Yeah looking at the code it looks like you want to abort execution when MONGO_URL is not set. So if we cannot use Deno.exit() we need to use something else to abort execution there. If we just remove it, then it would continue to run. What you normally do is wrap this part in an if-else statement or even a function.
if (!MONGO_URL) {
console.log("No mongo url found")
} else {
await mongoose.connect(MONGO_URL);
// ...etc
}
// END OF FILE
if (!MONGO_URL) {
console.log("No mongo url found")
} else {
await mongoose.connect(MONGO_URL);
// ...etc
}
// END OF FILE
The same written as a function:
async function bootServer() {
if (!MONGO_URL) {
console.log("No mongo url found")
return
}
await mongoose.connect(MONGO_URL);
// ...etc
}

await bootServer();
// END OF FILE
async function bootServer() {
if (!MONGO_URL) {
console.log("No mongo url found")
return
}
await mongoose.connect(MONGO_URL);
// ...etc
}

await bootServer();
// END OF FILE
JMvelasco
JMvelasco12mo ago
yeah i tried to wrap it in a if-else statement and now im getting the following error : ISOLATE_INTERNAL_FAILURE