Skip to content

Conversation

@karlseguin
Copy link
Collaborator

When calling a Zig function from JS fails due to a parameter type error, log.debug information about the function and parameters.

When calling a Zig function from JS fails due to a parameter type error,
log.debug information about the function and parameters.
Copy link
Contributor

@sjorsdonkers sjorsdonkers left a comment

Choose a reason for hiding this comment

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

How do I get this to print?
When I add an argument (to IntersectionObserver.observer()), I get nothing in the server terminal and the same invalid argument response to the client.

@karlseguin
Copy link
Collaborator Author

karlseguin commented May 15, 2025

It's a debugging tool, in case you're getting some JS error in a callback, and want to see what that callback is.

    pub fn constructor(callback: Env.Callback, options_: ?IntersectionObserverOptions, state: *SessionState) !IntersectionObserver {
        // ADDED
        try callback.printFunc();
        ....
$ make test F="Browser.DOM.IntersectionObserver"
() => {}
entries => {count_a += 1;}
entries => {count_b = entries.length;}
entries => {count_bb = entries.length;}
entries => { count_c = entries.length;}
entries => {}
entries => {}
entries => { entry = entries[0]; }
entries => { new_entry = entries[0]; }
Browser.DOM.IntersectionObserver (13.87ms)

Copy link
Contributor

@sjorsdonkers sjorsdonkers left a comment

Choose a reason for hiding this comment

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

Ah, got it.
We could look into always calling this when we have an invalid arguments error on a callback (in debug)

@karlseguin karlseguin merged commit ddd35e3 into main May 15, 2025
9 checks passed
@karlseguin karlseguin deleted the js_debug_helpers branch May 15, 2025 08:44
@github-actions github-actions bot locked and limited conversation to collaborators May 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants