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

Missing fields when using Bridge.call() from the Ruby side with mixed hashes #26

Open
merwaaan opened this issue Jun 1, 2021 · 0 comments

Comments

@merwaaan
Copy link

merwaaan commented Jun 1, 2021

Hi :)

I might have found a serialization bug.

I have this issue where some fields sent over from the Ruby side are missing on the JS side. After a lot of testing, it seems to be happening with mixed Ruby hashes (with both symbols and string keys) sent via call().

How to reproduce from the Ruby side:

hash1 = { # all symbols, will work fine
  a: 1,
  b: 'hello'
}

hash2 = { # all strings, will work fine
  'a' => 1,
  'b' => 'hello'
}
 
hash3 = {  # mixed, b will be missing
  'a' => 1,
  b: 'hello'
}

call('test', hash1)
call('test', hash2)
call('test', hash3)

The output on the JS side:

test: Object {a: 1, b: "hello"}
test: Object {a: 1, b: "hello"}
test: Object {a: 1}

Interestingly, this does not happen when sending data via promise resolution:

on('test1') do |deferred|
  deferred.resolve({ a: 1, b: 'hello' })
end

on('test2') do |deferred|
  deferred.resolve({ 'a' => 1, 'b' => 'hello' })
end

# This time it works
on('test3') do |deferred|
  deferred.resolve({ 'a' => 1, b: 'hello' })
end

So maybe there's a serialization inconsistency between call() and resolve()?

I tried poking a bit in the code but at first glance I cannot see what goes wrong.

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

No branches or pull requests

1 participant