* Set `node-fetch` to `^2.7.0`
* Update package-lock.json
```
# root
bin/npm update node-fetch
bin/npm update cross-fetch
# in other path in docker
npm update node-fetch
```
* Update node-fetch patch
* [fetch-utils] Skip the test: destroys the request body if it doesn't get consumed
```
1) fetch-utils
fetchJson
destroys the request body if it doesn't get consumed:
FetchError: Invalid response body while trying to fetch http://example.com:30001/json/ignore-request: write EPIPE
at PassThrough.<anonymous> (/overleaf/node_modules/node-fetch/lib/index.js:400:12)
at PassThrough.emit (node:events:529:35)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
```
* [fetch-utils] Delete the test: destroys the request body if it doesn't get consumed
* Remove the `setTimeout` in the node-fetch patch
Fixes a test and doesn't break filestore acceptance tests
* Update node-fetch patch again: bring changes from https://github.com/node-fetch/node-fetch/blob/e87b093/src/index.js
* Update node-fetch patch again: bring changes from https://github.com/node-fetch/node-fetch/blob/e87b093/src/index.js
* Update node-fetch patches back to single lines
Per https://github.com/overleaf/internal/pull/20165#discussion_r1739035513
GitOrigin-RevId: 945e5a12e838673b7bc87b588b7aca1bcd9109e2
* [web] CE script to verify TexLive versions on startup
---------
Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com>
GitOrigin-RevId: b99001d38468a775991a7284611aa333e956b919
* Add some JSDoc types to `@overleaf/logger`
* Update `logger.error` calls
* Fixup `logger.err` JSDoc
* Update `logger.err` calls
* Fix `args` type
* Remove "Error message" description
* Replace `arguments` by actual arguments of the method
* Fix: "ESLint: Unnecessary '.apply()'.(no-useless-call)"
* Add JSDoc params to `debug` `info` `warn`
* Remove extra `args` param in JSDoc so developers aren't invited to use it
Not sure if this is the best thing to do because it creates a warning in the IDE: "Parameter args is not described in JSDoc"
* Add comment about serialization of `err` `req` `res`
* Allow strings as first param in `debug` `info` `warn`
* Fix syntax for optional parameters in JSDoc
* Add 2 signatures, to avoid "string, string" params
* Fix `@signature` names copy-pastes
Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com>
* Revert the double `@param attributes`. It doesn't work
---------
Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com>
GitOrigin-RevId: 086dee8bbf30d577c5e1f844a9df5e518c46aca7
* Don't send status 200 in the beginning: we may throw later
This was causing `Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client`
https://cloudlogging.app.goo.gl/Bchegw2iCYLxhPNk8
* Continue when failing to send one email, but log the error
* Revert "Don't send status 200...", log error instead
This reverts commit 3e13559704f822e330a18a68567f46491649f222.
* Fix `logger.error` params
* Fixup: good syntax for `logger.error`
* Remove useless `OError` import
* Update services/web/modules/metrics/app/src/MetricsEmailController.js
Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com>
* Update services/web/modules/metrics/app/src/MetricsEmailController.js
Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com>
* Update services/web/modules/metrics/app/src/MetricsEmailController.js
Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com>
* Update services/web/scripts/recurly/collect_paypal_past_due_invoice.js
Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com>
---------
Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com>
GitOrigin-RevId: c68bc677326729fc6c39b7c2f027e35ebb776bd2
* Create `getPaginatedEndpointIterator` to iterate each page
* Create `waitMs` util, it will replace `slowCallback`
* Make `handleAPIError` async
* Make `isAccountUsingPaypal` async
* Make `attemptInvoiceCollection` async
* Make `attemptInvoicesCollection` async
* Use `await` instead of `new Promise`
* Remove unused callbackified `attemptInvoiceCollection`
* Run `attemptInvoiceCollection` for each page instead of gathering all pages in the beginning
* Add test on fetching multiple pages of invoice
GitOrigin-RevId: 2674b18c6ca5732b873fb2bc71b515909006f93d
* Rename `RecurlyWrapper` to `promises`, as it will only contain the promises soon
* Update `apiRequest`
* Update `_parseXml`
* Update `_parseXmlAndGetAttribute`
* Update `_parse*Xml`
* Update `updateAccountEmailAddress`
* Update `checkAccountExists`
* Update `createAccount`
* Update `createBillingInfo`
* Update `setAddressAndCompanyBillingInfo`
* Update `createSubscription`
* Update `_createPaypalSubscription`
* Update `_handle422Response`
* Update `_createCreditCardSubscription`
* Update `createSubscription`
* Update `getSubscriptions`
* Update `getSubscription`
* Update `getPaginatedEndpoint`
* Update `getAccount`
* Update `getAccountActiveCoupons`
* Update `getCoupon`
* Update `getBillingInfo`
* Update `getAccountPastDueInvoices`
* Update `attemptInvoiceCollection`
* Update `updateSubscription`
* Update `createFixedAmmountCoupon`
* Update `lookupCoupon`
* Update `redeemCoupon`
* Update `extendTrial`
* Update `listAccountActiveSubscriptions`
* To find which functions to add as callbackified, I used this Regex:
`RecurlyWrapper\.(?!promises)[^.\s]*`
And after adding callbackified functions, we're left with no results with the Regex:
`RecurlyWrapper\.(?!promises|apiUrl|_buildXml|_parseXml|attemptInvoiceCollection|createFixedAmmountCoupon|getAccountActiveCoupons|getBillingInfo|getPaginatedEndpoint|getSubscription|updateAccountEmailAddress)[^.\s]*`
* Update unit tests
* Test `getSubscription` both as "promise" and as "callback"
I'm not sure if we want to generalize this.
* Fix: add missing `await`s (!!)
* Change `apiRequest` to reject errors instead of resolving it in an object
* Fixup for CollectPayPalPastDueInvoice test
* Fix: callbackify `getSubscriptions` (!!)
* Replace `.then(...)` chain by multiple `await`
* Fixup `attemptInvoicesCollection`: prevent reading length of undefined
* Use `return await` when returning promises
Per https://github.com/overleaf/internal/pull/18384#pullrequestreview-2065738771
GitOrigin-RevId: ceda755b24fd29f97a27e60ac5db9bc7e369f932
* Fix `revokeAllUserSessions` call in `_cleanupUser`
The user object should be passed, not the _id
* Change `revokeAllUserSessions` signature, take `req` and `stayLoggedIn` arguments
* Update uses of `revokeAllUserSessions`
* Fix promisified `revokeAllUserSessions` args
* Update tests
* Destroy or Regenerate the session in the end of `revokeAllUserSessions`
Per https://github.com/overleaf/internal/issues/17036#issuecomment-1938398570
* Revert "Destroy or Regenerate the session in the end of `revokeAllUserSessions`"
This reverts commit fe30734dbe45b27d2931d2e43a711d591bb85787.
* Rename `revokeAllUserSessions` to `removeSessionsFromRedis`
* Fixup tests
* Fix: add optional chaining in `req.sessionID` (!!)
GitOrigin-RevId: d41676bf00f463230af495e09c65fb9ee521f49f
* Fix: Invoices collected array length comparison
Update the code with the correct condition to respect the intent of the previous implementation ("exit with non zero code when no invoicess were processed").
See 5476f39984
However, I'm not sure if erroring when no invoices are collected is actually what we want to do.
* Wrap `collect_paypal_past_due_invoice` script and export the function
* Fixup typo `accoutns`
* Log invoices collection data before throwing
* Add note: `handleAPIError` is silencing the errors
* Create a test on `collect_paypal_past_due_invoice`
* Replace `console.log` by `@overleaf/logger` (bunyan)
Our `console.warn` show up as Errors (in red) in GCP. For example the following is an error in GCP:
```
Errors in attemptInvoiceCollection with id=2693634 OError: Recurly API returned with status code: 400
```
https://github.com/overleaf/internal/blob/5476f39/services/web/scripts/recurly/collect_paypal_past_due_invoice.js#L9
---
Does it correctly set the levels as warnings if we use `@overleaf/logger`
GitOrigin-RevId: 37c8bdf4afd8cef4706700aafb44480ec8966a74
* Copy `migration_compile_timeout_60s_to_20s.js` script
* Update `featuresUpdatedAt`
* Add a comment about `featuresUpdatedAt` in migration_compile_timeout_60s_to_20s.js
* Fix test on migration_compile_timeout_60s_to_20s.js
* Fix: Include users having `featuresUpdatedAt` undefined in the update
* Add test on `migration_compile_timeout_60s_to_20s_fixup_features_updated_at`
GitOrigin-RevId: 4b2baf955a6a9f39bf9ce00b7839af551064c6cb