Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Revert deletion of workaround for unordered SEND/RECV " #34

Merged
merged 2 commits into from
Dec 2, 2020

Conversation

YusukeIwaki
Copy link
Owner

@YusukeIwaki YusukeIwaki commented Dec 2, 2020

Reverts #32

raw_send was

    payload = JSON.fast_generate(message.compact.merge(id: id))
    @transport.send_text(payload)
    ### handle_message can be called here ###
    request_debug_printer.handle_payload(payload)
    id
    id = @connection.raw_send(message: { sessionId: @session_id, method: method, params: params })
    @callbacks[id] = MessageCallback.new(method: method, promise: promise)

With this implementation, we cannot handle message before raw_send returns the id.
If handle_message is called soon after send_text, it causes unknown id error, because the caller doesn't know the generated id.

So I changed this implementation. id is generated in advance, and raw_send just send text with given id.

    @connection.generate_id do |id|
      @callbacks[id] = Puppeteer::Connection::MessageCallback.new(method: method, promise: promise)
      @connection.raw_send(id: id, message: { sessionId: @session_id, method: method, params: params })
    end

@YusukeIwaki YusukeIwaki marked this pull request as ready for review December 2, 2020 19:04
@YusukeIwaki YusukeIwaki merged commit 578b940 into master Dec 2, 2020
@YusukeIwaki YusukeIwaki deleted the revert-32-revert_workaround_for_send_recv branch December 2, 2020 20:09
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.

1 participant