Giter Site home page Giter Site logo

Comments (2)

jeremydrichardson avatar jeremydrichardson commented on May 20, 2024

So looks like I got to the bottom of the issue finally.

What was actually happening was that 2 separate clients for the same FileMaker file were being created and somehow they were conflicting with each other.

A little more background in case it helps anyone:

Normally you would initialize a database connection when the app first runs. Then all requests can count on that database connection being open. However, due to the FileMaker API design, in our case we need to initialize the database using fms-api-client on first request. This is because we have multiple users and we need to login to the FileMaker file with that specific username. If we were to initialize when the app started we'd have a huge number of clients initialized, one for each user. Then because we have multiple files we'd need to do a new client for each user * each file. That gets exponentially huge.

Our idea was to build Express middleware that would check the fms-api-client marpat store to see if there is a client already made for that user/database, and if not, initialize one.

// Check if this client already exists
  const existingClient = await Filemaker.findOne({
    name: `${user}-${database}`,
  });

Conceptually it worked great, however every so often we would get a request that never finished. The issue was that if 2 request came in from the same user for the same file, it would create 2 clients. This was due to the first client not being created when the 2nd request was processed so it thought it needed to create another client.

The answer was a little complicated and required storing each client in the express app.locals variable which would happen instantaneously. Of course it would start a promise so we needed to await any promises before allowing the request to proceed.

Anyway, if anyone is interested in the solution I could DM since we're working on a closed source project.

Hope this helps someone since it was a couple days of troubleshooting to solve!

from fms-api-client.

daniel-heg avatar daniel-heg commented on May 20, 2024

Hi,
I am struggeling with the same problem for a week now.
It would be great if you could help me with your solution.
What would be the best way to get in contact with you?

from fms-api-client.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.