Skip to content

fix(plugins): Log potential errors in HTTP request callbacks - #6452

Merged
Mm2PL merged 3 commits into
Chatterino:masterfrom
Nerixyz:fix/log-http-cb-errors
Nov 5, 2025
Merged

Mm2PL merged 3 commits into
Chatterino:masterfrom
Nerixyz:fix/log-http-cb-errors

Conversation

@Nerixyz

@Nerixyz Nerixyz commented Sep 6, 2025

Copy link
Copy Markdown
Contributor

When an error occurred in a handler for an HTTP request, it wasn't printed to the console or the REPL (linked issue).
With this PR, the error is printed.

To test this, you can try the code from #6224 (comment) - it should only print "finally" in the chat. It should (with this PR) print an error like chatterino.lua: [test:Test plugin] HTTPRequest::on_error - (path): attempt to concatenate a nil value in both the Chatterino log as well the REPL. Before this, there was no output.

Fixes #6224.

self->cbError = std::nullopt;
})
.finally([mainState, hack]() {
.finally([pl, hack]() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note: we can just pass the plugin pointer here, because the plugin owns hack (see line 117).

I think, in the future, we could have some more generic plugin handle that we could store here (the plugin shouldn't need to know that HTTP requests exist). We can't put the plugin in a std::shared_ptr itself, but we could make the plugin own some shared pointer. That's for the next release, though.

@pajlada
pajlada requested a review from Mm2PL September 7, 2025 09:55
@pajlada

pajlada commented Nov 1, 2025

Copy link
Copy Markdown
Member

CC @Mm2PL

@pajlada pajlada assigned pajlada and Mm2PL and unassigned pajlada Nov 2, 2025

@Mm2PL Mm2PL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Mm2PL
Mm2PL enabled auto-merge (squash) November 5, 2025 00:52
@Mm2PL
Mm2PL merged commit ac33af2 into Chatterino:master Nov 5, 2025
18 checks passed
Pietro228 pushed a commit to Stream-Ally/streamally-chatterino that referenced this pull request Dec 5, 2025
…ino#6452)

Reviewed-by: Mm2PL <mm2pl+gh@kotmisia.pl>
Reviewed-by: pajlada <rasmus.karlsson@pajlada.com>
babicekmarek pushed a commit to babicekmarek/streamally-chatterino that referenced this pull request Sep 14, 2026
…ino#6452)

Reviewed-by: Mm2PL <mm2pl+gh@kotmisia.pl>
Reviewed-by: pajlada <rasmus.karlsson@pajlada.com>
babicekmarek pushed a commit to babicekmarek/streamally-chatterino that referenced this pull request Sep 14, 2026
…ino#6452)

Reviewed-by: Mm2PL <mm2pl+gh@kotmisia.pl>
Reviewed-by: pajlada <rasmus.karlsson@pajlada.com>
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.

Lua HTTPRequest fails to report callbacks' errors

3 participants