Skip to content

Conversation

@masenf
Copy link
Collaborator

@masenf masenf commented Nov 7, 2025

There was also another place in the call_script callback path where the incorrect parameters have been passed since at least 0.8 🙀

There was also another place in the call_script callback path where the
incorrect parameters have been passed since at least 0.8 🙀
@linear
Copy link

linear bot commented Nov 7, 2025

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 7, 2025

CodSpeed Performance Report

Merging #5962 will not alter performance

Comparing masenf/queue-events-params (bcf07eb) with main (fd6e111)

Summary

✅ 8 untouched

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR fixes parameter passing issues to queueEvents and processEvent that have existed since the Remix migration (v0.8). The functions' signatures were updated to require 5 and 3 parameters respectively, but several call sites were still using the old signatures.

Changes made:

  • state.js: Added missing prepend parameter (value: false) to queueEvents call in queueEventIfSocketExists function
  • state.js: Replaced direct queueEvents calls with queueEventIfSocketExists for _clear_session_storage and _remove_session_storage events to ensure proper null checking
  • format.py: Updated format_queue_events to generate JavaScript code that passes all required parameters (prepend, navigate, params) when calling queueEvents and processEvent

The fix ensures that callback functions generated by rx.call_script now correctly queue events with all required parameters.

Confidence Score: 5/5

  • This PR is safe to merge - it fixes critical bugs in parameter passing that could cause runtime errors
  • The changes are straightforward bug fixes that correct parameter mismatches between function signatures and call sites. All modifications follow existing patterns in the codebase, and the fix addresses issues that have existed since v0.8. No logic changes were made beyond adding the missing parameters.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
reflex/.templates/web/utils/state.js 5/5 Fixed parameter passing to queueEvents by adding missing prepend parameter and replaced direct queueEvents calls with queueEventIfSocketExists for session storage events
reflex/utils/format.py 5/5 Updated format_queue_events to pass all required parameters (prepend, navigate, params) to queueEvents and processEvent functions in generated JavaScript code

Sequence Diagram

sequenceDiagram
    participant Script as rx.call_script
    participant Format as format_queue_events
    participant JS as Generated JS
    participant Queue as queueEvents
    participant Process as processEvent
    participant Socket as WebSocket

    Note over Script,Format: Python Side (Backend)
    Script->>Format: format_queue_events(events)
    Format->>JS: Generate callback function
    Note over JS: OLD: queueEvents([...], socket)<br/>NEW: queueEvents([...], socket, false, navigate, params)
    
    Note over JS,Socket: JavaScript Side (Frontend)
    JS->>Queue: Call with 5 parameters
    Note over Queue: events, socket, prepend, navigate, params
    Queue->>Process: processEvent(socket, navigate, params)
    Process->>Socket: emit("event", event)
    
    Note over Script,Socket: Session Storage Events
    alt _clear_session_storage or _remove_session_storage
        JS->>Queue: OLD: queueEvents(initialEvents(), socket, navigate, params)
        Note over Queue: Missing prepend parameter!
        JS->>Queue: NEW: queueEventIfSocketExists(initialEvents(), socket, navigate, params)
        Queue->>Queue: Adds false for prepend internally
    end
Loading

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@masenf masenf merged commit 3c3ddc2 into main Nov 10, 2025
47 checks passed
@masenf masenf deleted the masenf/queue-events-params branch November 10, 2025 18:28
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