Skip to content

Sessions not being reused when having multiple concurrent requests #110

Open
@earamizu

Description

@earamizu

Describe the bug
Requests being made almost concurrently are not seeing each other's sessions connected to FMS causing it to use the same session. For example, we have a button on a page that triggers a hook on FM that waits for 5 seconds. When there's no existent client and we click on this button twice, we see it creating and reusing the new client, but only the last session is being saved to the database (We're using NeDB for this). Once both calls come back, if we click on the button twice again, we'll see that both requests were done using the same session, therefore, running the requests sequentially.

Expected behavior
Sessions being used updated on the fly on the database (NeDB) so if a new request comes in, it would see that the current session is being used and it would create a new one for this new request so it would run the requests concurrently.

Tests
Following are some logs that we can see this issue.

First two calls (no client object saved to the database):

dapiClient id: YOAmXDfqSfs4TGsw
Concurrency: 5
Total Sessions: 1
Sessions:
0: 3bce0ff2-ec9f-4dc0-8d44-d7e628482d7b     active: false
/script_625: 5547.687ms
dapiClient id: YOAmXDfqSfs4TGsw
Concurrency: 5
Total Sessions: 1
Sessions:
0: 0cbd5ac1-1005-4db9-8b54-04011d16d55e     active: false
/script_538: 5536.370ms

Following calls:

dapiClient id: YOAmXDfqSfs4TGsw
Concurrency: 5
Total Sessions: 1
Sessions:
0: 0cbd5ac1-1005-4db9-8b54-04011d16d55e     active: false
/script_124: 5107.766ms
dapiClient id: YOAmXDfqSfs4TGsw
Concurrency: 5
Total Sessions: 1
Sessions:
0: 0cbd5ac1-1005-4db9-8b54-04011d16d55e     active: false
/script_311: 9710.650ms

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions