You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When creating 2 separate fms-api-client clients for different files, and making a single async calls with each client, the second call will fail.
Expected behavior
It's unexpected that completely separate clients would affect each other. It seems as though there is some sort of collision between the clients that is causing the wrong token to be used.
Code Examples
const{ Filemaker }=require("fms-api-client");const{ connect }=require("marpat");require("dotenv").config({path: "./.env"});connect("nedb://memory").then(()=>{constfmsApiClient1=Filemaker.create({name: `client-database1`,database: "database1",concurrency: 30,server: `${process.env.URL}`,user: `${process.env.USERNAME}`,password: `${process.env.PASSWORD}`,usage: true,timeout: 60000,});constclient1=fmsApiClient1.save();constfmsApiClient2=Filemaker.create({name: `client-database2`,database: "database2",concurrency: 30,server: `${process.env.URL}`,user: `${process.env.USERNAME}`,password: `${process.env.PASSWORD}`,usage: true,timeout: 60000,});constclient2=fmsApiClient2.save();Promise.all([client1,client2]).then(([db1Client,db2Client])=>{db1Client.layout("REST_Value_Lists").then((result)=>{console.log("Result of db1Client");}).catch((err)=>{console.log("Error of db1Client");});db2Client.layout("REST_Value_Lists").then((result)=>{console.log("Result of db2Client");}).catch((err)=>{console.log("Error of db2Client");});})});
Additional context
I'm not sure really where to look on this one. Any help knowing where to look would be great. Have VS Code debugger hooked up but still not being able to really track what it going on.
How does fms-api-client decide when to look for a new token. Seems to be in the agent.model file but can't track it down.
Thanks
The text was updated successfully, but these errors were encountered:
The issue is that in the agent model, the axios instance is being shared by every client. There is some race condition where another request is made before the previous request promise has resolved.
The fix is to create an instance that is local to the agent class and call that instead of the global axios instance.
Here is our code that extends the Client model and adds the localized axios instance to the agent and replaces the agent request method with one that uses this.instance instead of just instance.
I'll see if I can make a pull request that would fix it in the agent model. The tricky part is making sure it can accomodate an external agent.
Describe the bug
When creating 2 separate fms-api-client clients for different files, and making a single async calls with each client, the second call will fail.
Expected behavior
It's unexpected that completely separate clients would affect each other. It seems as though there is some sort of collision between the clients that is causing the wrong token to be used.
Code Examples
Additional context
I'm not sure really where to look on this one. Any help knowing where to look would be great. Have VS Code debugger hooked up but still not being able to really track what it going on.
How does fms-api-client decide when to look for a new token. Seems to be in the agent.model file but can't track it down.
Thanks
The text was updated successfully, but these errors were encountered: