-
-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use promises instead of callbacks, when calling mongodb, so we can upgrade it #634
Open
5 of 8 tasks
Labels
Comments
13 tasks
Merged
adrienjoly
added a commit
that referenced
this issue
Aug 23, 2023
Follow up of PR #666. Contribute to #634. => From 219 to 209 warnings left to fix. * fix `'parse' is deprecated. Use the WHATWG URL API instead` * fix `Callbacks are deprecated` in activity model * fix `Callbacks are deprecated` in comment model * fix `Callbacks are deprecated` in follow model * make test diff more legible cf https://github.com/openwhyd/openwhyd/actions/runs/5953409421/job/16147584118?pr=676#step:6:177 * fix call to dbHandler in follow:add() cf https://github.com/openwhyd/openwhyd/actions/runs/5953409421/job/16147584118?pr=676#step:6:177 * fix test for correctness + legible diff display * reset-test-db.js: don't fail if upload directories don't exist at startup cf https://github.com/openwhyd/openwhyd/actions/runs/5953568519/job/16148115227?pr=676#step:4:19 * apply sonarcloud recommendations
adrienjoly
added a commit
that referenced
this issue
Aug 24, 2023
Follow up of PRs #677, #676 and #666. Contributes to #634. * fix `Callbacks are deprecated` in notif model * delete deprecated mongodb options found by `@ts-check` * fix `Property 'then' does not exist on type 'FindCursor<Document>'.` * refactor: line whenDone() in forEach() * fix: move whenDone() to then() * refactor: flatten callback hell using await * fix: forEach() doesn't pass any `error` + flatten `clearUserNotifs` again * 😅 making TypeScript analysis loop infinitely when trying to type db.notif, so that $pull operation is seen as valid cf https://stackoverflow.com/a/67043340/592254 * ignore false alert on $pull from typescript checker cf https://www.mongodb.com/community/forums/t/type-objectid-is-not-assignable-to-type-never/139699 * fix deprecations + callback hell in notif model * ignore `Expected 0-1 arguments, but got 2.` ts errors * fix remaining deprecation warnings in notif model * fix `callback is not a function` error revealed by `hot-tracks` approval tests * apply suggestion from codacy * apply suggestion from sonarcloud: Prefer using an optional chain expression instead, as it's more concise and easier to read. cf https://sonarcloud.io/project/issues?resolved=false&types=CODE_SMELL&pullRequest=678&id=openwhyd_openwhyd&open=AYomPq2Mlp4D0TuBpJrq
adrienjoly
added a commit
that referenced
this issue
Aug 24, 2023
=> I just rolled back production to v1.55.19 |
adrienjoly
added a commit
that referenced
this issue
Aug 29, 2023
Contributes to #634. * fix callbacks passed to mongodb, in post model * fix counter of refs to deprecated `usernames` cache cause: some refs were probably not detected earlier, because of complicated callback logic contributes to #580. * fix(codacy): Always provide a base when using parseInt() functions * check for TypeScript errors in `post.js` * fix `Property 'nbPostsPerNewsfeedPage' does not exist on type 'typeof import("/Users/adrienjoly/Code/openwhyd/app/models/config")'` * fix deprecated mongodb options * fix `Cannot read properties of undefined (reading 'nbPostsPerNewsfeedPage')` cf https://github.com/openwhyd/openwhyd/actions/runs/5983938243/job/16234633467?pr=680#step:7:22 * add test: `incrPlayCounter` action should increase the number of plays of the track * add failing test: `incrPlayCounter` action should return the post _id * fix(api): incrPlayCounter action to not return the `post` object anymore !BREAKING * add failing test: `should increase the total number of plays of that track` => make sure that db is cleared between each test * fix test `post api should add a track to a new playlist`, to make it isolated/independant from other tests of the suite * fix test: `should increase the total number of plays of that track`, as `track` documents are created lazily * test should not pass => make `updateByEid` assert that `eId` param is defined * fix test by setting a eId * fix `incrPlayCounter` impl. by fetching the post's eId * playlist tests: prevent side effects between tests * refactor: extract callPlaylistApi * playlist tests: use DUMMY_USER instead of ADMIN_USER * playlist tests: make sure that freshly created playlist is persisted in db * add test: should rename a playlist * add failing test: should update the playlist's name in associated posts * fix: userModel.setPlaylist to await the update of posts * fix test, to match with schema of posts * be more decisive on when to cleanup, in post.api.tests.js * skip tests that cause side effects on other tests example for #684. * fix(sonar): `Promise returned in function argument where a void return was expected.` * 🙌 re-enable all playlist api tests * remove callback from setPlaylist() * add tests for playlist removal and its impact on associated posts * remove callback from unsetPlaylist() * fix some error cases, based on code review * simplify call expression * refactor: move up insertPost() and callPostApi() helpers * add tests for toggleLovePost * reveal missing callbacks in setPostLove * remove callback from setPostLove()
adrienjoly
added a commit
that referenced
this issue
Sep 2, 2023
adrienjoly
pushed a commit
that referenced
this issue
Sep 2, 2023
adrienjoly
added a commit
that referenced
this issue
Sep 11, 2023
- argon2 ^0.31.0 → ^0.31.1, because we're developing an alternative: #705 - connect-mongo ^3.2.0 → ^5.0.0, because we're developing an alternative: #705 - formidable ^2.1.1 → ^3.5.1, because it breaks the build (cf #709 and #665) - mongodb 4.17.0 → 6.0.0, because we're not done yet on migrative callbacks to promises (cf #634 and #665) This partially reverts commit 43a63cf.
adrienjoly
added a commit
that referenced
this issue
Sep 11, 2023
`$ npx npm-check-updates -u` Updates: - @applitools/eyes-cypress ^3.37.0 → ^3.38.0 - @cypress/code-coverage ^3.11.0 → ^3.12.0 - @types/node ^20.5.7 → ^20.6.0 - approvals ^6.2.1 → ^6.2.2 - cypress ^12.17.4 → ^13.1.0 - dd-trace ^4.14.0 → ^4.15.0 - eslint ^8.48.0 → ^8.49.0 Skipped updates: - argon2 ^0.31.0 → ^0.31.1, because we're developing an alternative: #705 - connect-mongo ^3.2.0 → ^5.0.0, because we're developing an alternative: #705 - formidable ^2.1.1 → ^3.5.1, because it breaks the build (cf #709 and #665) - mongodb 4.17.0 → 6.0.0, because we're not done yet on migrative callbacks to promises (cf #634 and #665)
adrienjoly
added a commit
that referenced
this issue
Nov 4, 2023
## What does this PR do / solve? Whenever a db error happens during the generation of a notification digest email, the `notifEmails` worker hangs, causing a loop of `[OneAtATime] fct is trying to start before last call has ended` errors. <img width="1185" alt="image" src="https://github.com/openwhyd/openwhyd/assets/531781/5ad3533b-2e38-4d90-8ba0-566f47049cb7"> The problem was probably revealed while migrating on #634, because of not calling "`cb`" callback functions in case of errors returned by `async` mongodb calls. ## Overview of changes - Intercept errors, so the execution of the worker can end and be restarted later in case of unexpected interruption. - => turn callback-based functions into `async` functions, so that errors can be intercepted.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now that we have upgraded mongodb driver from v3 to v4 (see #630), we should migrate callbacks to promises.
Why? As shown in #665 (comment), upgrading MongoDB 4 --> 5 cause TypeScript errors because of callbacks being passed to mongodb-driver, cf https://github.com/openwhyd/openwhyd/actions/runs/5912435427/job/16035845596#step:6:43.
For instance:
activity
modelcomment
modelnotif
modelpost
modeltrack
modelfollow
modeluser
model// @ts-check
to all models => fix TS errors=> When all calls are fixes, let's upgrade to mongodb driver v5.
The text was updated successfully, but these errors were encountered: