Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lffg-archive/adonisjs-lucid-hooks-race-condition-problem
https://github.com/lffg-archive/adonisjs-lucid-hooks-race-condition-problem
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/lffg-archive/adonisjs-lucid-hooks-race-condition-problem
- Owner: lffg-archive
- Created: 2020-05-04T20:59:12.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-09T22:56:53.000Z (almost 2 years ago)
- Last Synced: 2024-04-24T23:02:41.548Z (9 months ago)
- Language: TypeScript
- Size: 1.09 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AdonisJs Lucid Hooks Race Condition Problem
I created this repository in order to demonstrate a race condition problem that Lucid Hooks are susceptible for. As you can check in `start/routes.ts` file, when a lucid model with a hook is updated multiple times at once, the hook does not "catch" the new states, causing a race condition problem.
If you start a server and go to http://localhost:3333/exec-test-linear, you will see that the `count` field matches the times that the record was updated (50). However, when the record is updated at the same time (I've used `Promise.all` to achieve that), the hook suffers from a race-condition problem.
You can test for this wrong behavior at http://localhost:3333/exec-test-parallel.
I think that a type of FIFO queue should be implemented to avoid this kind of problems.