Skip to content

Conversation

@thehabes
Copy link
Member

@thehabes thehabes commented Jul 8, 2025

No description provided.

@thehabes thehabes marked this pull request as ready for review July 8, 2025 22:43
@thehabes thehabes requested a review from cubap as a code owner July 8, 2025 22:43
@cubap
Copy link
Member

cubap commented Jul 9, 2025

That's a shiny PR
image

Copy link
Member

@cubap cubap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm okay with this. I didn't break it. I have some comments, but the most general one is that this is only TinyThings and not TinyPEN. If that is good with you - send it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically as middle ware I think the rerum response would come last but I see you

rerum_err_text = undefined
}
if (rerum_err_text) error.message = rerum_err_text
else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know I would have put a ternary because I hate "else" but it is kinda an else anyway.
However, no braces and then braces for this block pair was a bold move.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah i might have had more than one line in there at one point

// Perhaps this is a more generic 500 from the app, perhaps involving RERUM, and there is no good rerum_error_res
error.message = rerum_error_res.statusMessage ?? rerum_error_res.message ?? `A server error has occured`
}
error.status = rerum_error_res.statusCode ?? rerum_error_res.status ?? 500
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct and I hate it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a trip

error.status = rerum_error_res.statusCode ?? rerum_error_res.status ?? 500
console.error(error)
res.set("Content-Type", "text/plain; charset=utf-8")
res.status(error.status).send(error.message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means messenger can never have a payload...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now. We didn't respond anywhere with a payload. If we end up wanting to do that we can upgrade the messenger.

// Special handling. This does not go through to error-messenger.js
if (rerum_res.status === 409) {
const currentVersion = await rerum_res.json()
return res.status(409).json(currentVersion)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sends it, it doesn't keep going.

if(res.headersSent) return
const result = await response.json()
// Send RERUM error responses to error-messenger.js
if (errored) return next(response)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order of this makes me a little uneasy, but it works.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes trying to keep separate what errors are here.

throw new Error(`Error in overwrite request: ${err.status} ${err.statusText}`)
return rerum_res
})
.catch(err => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why catch to only throw?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of them do it, so I thought maybe we did it for a reason. At least doing it to be consistent.

@thehabes thehabes merged commit fe43b95 into main Jul 9, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants