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

bert.js decode error on the server: badarg #317

Closed
xafizoff opened this issue Jan 24, 2019 · 1 comment
Closed

bert.js decode error on the server: badarg #317

xafizoff opened this issue Jan 24, 2019 · 1 comment

Comments

@xafizoff
Copy link
Contributor

xafizoff commented Jan 24, 2019

listen() ->
    nitro:wire(#bind{target=svg,type=edit,postback=
                         ["ws.send(enc(tuple(atom('pickle'),atom('svg'),bin('",
                          n2o:pickle(#ev{module=?MODULE,msg={edit,svg},name=event}),
                          "'),list(tuple(atom('id'),number(event.detail.id)),",
                          "tuple(atom('action'),bin(event.detail.action)),",
                          "tuple(atom('svg'),querySource('svg'))",
                          "))));"]}).

event({edit,svg}) -> Id  = nitro:q(id),
                     Svg = #proc{flows=Flows,tasks=Tasks} = nitro:q(svg),
                     case nitro:q(action) of
                         <<"deleteflow">> -> {reply,Svg#proc{flows=[F||F<-Flows,F#flow.id/=Id]}};
                         <<"edittask">> -> ok end;

This works nicely, but if I change bin(event.detail.action) to atom(event.detail.action) I get

{[{reason,badarg},
  {mfa,{n2o_stream,websocket_handle,3}},
  {stacktrace,
      [{erlang,binary_to_term,
           [<<131,104,4,100,0,6,112,105,99,107,108,101,100,0,3,115,118,103,109,
              0,0,0,192,57,97,53,98...
           >>], [safe]], []}, 
           ...
@xafizoff xafizoff changed the title bert.js encode tuple with subsequent atoms bert.js encode tuple with 2 atoms Jan 24, 2019
@xafizoff xafizoff changed the title bert.js encode tuple with 2 atoms bert.js decode error on the server: badarg Jan 25, 2019
@xafizoff
Copy link
Contributor Author

My atom is not registered in the virtual machine. See #3

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