Error 1101 on code surrounded by try/catch

I'm deploying a Nuxt.js application and my pages event handler is being called but somehow seems to just "stop" executing code and I get the Error 1101 message. The reason I say stop is that I've added console.log lines between every single statement to pinpoint what is going on and the entire thing is wrapped in a try catch block but the catch is never being called.
1 Reply
bnason
bnasonOP6mo ago
import { SAML } from 'saml-login'

export default defineEventHandler(async (event) => {
try {
console.log(1)
const saml = new SAML()

console.log(2)
const options: Parameters<typeof saml.generateAuthenticationUrl>[0] = {
providerSingleSignOnUrl: 'xxx',
applicationEntityId: 'xxx',
applicationCallbackAssertionConsumerServiceUrl: `http${process.env.NODE_ENV === 'production' ? 's' : ''}://${
process.env.SITE_DOMAIN
}/auth/saml/sp/acs`,
allowCreate: false,
}
console.log(3)
const redirectUrl = await saml.generateAuthenticationUrl(options)

console.log(4)
sendRedirect(event, redirectUrl)

console.log(5)
return ''
} catch (e) {
console.log(6)
if (e instanceof Error) {
console.log(e.message)
}

return 'error'
}
})
import { SAML } from 'saml-login'

export default defineEventHandler(async (event) => {
try {
console.log(1)
const saml = new SAML()

console.log(2)
const options: Parameters<typeof saml.generateAuthenticationUrl>[0] = {
providerSingleSignOnUrl: 'xxx',
applicationEntityId: 'xxx',
applicationCallbackAssertionConsumerServiceUrl: `http${process.env.NODE_ENV === 'production' ? 's' : ''}://${
process.env.SITE_DOMAIN
}/auth/saml/sp/acs`,
allowCreate: false,
}
console.log(3)
const redirectUrl = await saml.generateAuthenticationUrl(options)

console.log(4)
sendRedirect(event, redirectUrl)

console.log(5)
return ''
} catch (e) {
console.log(6)
if (e instanceof Error) {
console.log(e.message)
}

return 'error'
}
})
This is what tailing the logs shows:
{
"outcome": "exception",
"scriptName": "pages-worker--3037681-production",
"diagnosticsChannelEvents": [],
"exceptions": [
{
"name": "Error",
"message": "The script will never generate a response.",
"timestamp": 1719317831505
}
],
"logs": [
{
"message": [
1
],
"level": "log",
"timestamp": 1719317831505
},
{
"message": [
2
],
"level": "log",
"timestamp": 1719317831505
},
{
"message": [
3
],
"level": "log",
"timestamp": 1719317831505
}
],
"eventTimestamp": 1719317831505,
"event": {
"response": {
"status": 500
}
},
"id": 1
}
{
"outcome": "exception",
"scriptName": "pages-worker--3037681-production",
"diagnosticsChannelEvents": [],
"exceptions": [
{
"name": "Error",
"message": "The script will never generate a response.",
"timestamp": 1719317831505
}
],
"logs": [
{
"message": [
1
],
"level": "log",
"timestamp": 1719317831505
},
{
"message": [
2
],
"level": "log",
"timestamp": 1719317831505
},
{
"message": [
3
],
"level": "log",
"timestamp": 1719317831505
}
],
"eventTimestamp": 1719317831505,
"event": {
"response": {
"status": 500
}
},
"id": 1
}
As you can see it stops on console.log(3) but it should show console.log(6) if there was an exception thrown!
Want results from more Discord servers?
Add your server