Simultaneous API calls fails

mickaelmickael
in CLI

Hi,

Another question again regarding the op CLI ;)

I use it in a scaffolding tool to generate all my credentials and ssh keys needed for a new server provisioning. The tool is written in NodeJS (Yeoman).

I discovered that when the requests were done in an asynchronous process (so simultaneously), the authentication fails.

Currently, 5 server password scripts were called. Each script does an authentication check then send the request.

I changed how the promises were resolved to handle them in a synchronous way. Things are working when the requests are emitted one after one.


1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
Sync Type: Not Provided

Comments

  • rickfillionrickfillion Junior Member

    Team Member

    Hrmm....

    This is likely due to how op handles creating unique identifiers for requests. The server requires that each request it receives has a unique (to the session) identifier. For our normal apps this is trivial as it's just a counter. For a short-lived process like the CLI tool, this is more challenging. On the CLI we base that identifier on amount of time since session creation. And so if two commands were run at the exact (or close enough) same time, then it's possible for them to pick the same identifier which results in the server rejecting the duplicates.

    We've been working on things to make this less likely, but our current recommendation is to not do concurrent requests with the CLI.

    Rick

  • @rickfillion Thanks for the explanation, I understand.

  • cohixcohix

    Team Member

    Let us know if you have any other questions!

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file