@openneuro/server 4.29.5 → 4.29.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openneuro/server",
|
|
3
|
-
"version": "4.29.
|
|
3
|
+
"version": "4.29.7",
|
|
4
4
|
"description": "Core service for the OpenNeuro platform.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "src/server.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@elastic/elasticsearch": "8.13.1",
|
|
22
22
|
"@graphql-tools/schema": "^10.0.0",
|
|
23
23
|
"@keyv/redis": "^2.7.0",
|
|
24
|
-
"@openneuro/search": "^4.29.
|
|
24
|
+
"@openneuro/search": "^4.29.7",
|
|
25
25
|
"@sentry/node": "^8.25.0",
|
|
26
26
|
"@sentry/profiling-node": "^8.25.0",
|
|
27
27
|
"base64url": "^3.0.0",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"publishConfig": {
|
|
86
86
|
"access": "public"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "a11e8c6dfe702377946a26e9d86234593465cd04"
|
|
89
89
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import CacheItem from "../item"
|
|
2
|
+
import { CacheType } from "../types"
|
|
3
|
+
|
|
4
|
+
const redisMock = vi.fn(() => ({
|
|
5
|
+
getBuffer: vi.fn(),
|
|
6
|
+
setex: vi.fn(),
|
|
7
|
+
set: vi.fn(),
|
|
8
|
+
}))
|
|
9
|
+
|
|
10
|
+
describe("CacheItem", () => {
|
|
11
|
+
it("should succeed when the cache miss sets doNotCache but throws an exception", async () => {
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
const item = new CacheItem(redisMock() as any, CacheType.commitFiles, [
|
|
14
|
+
"ds000001",
|
|
15
|
+
"12345678",
|
|
16
|
+
])
|
|
17
|
+
let fail = true
|
|
18
|
+
expect(
|
|
19
|
+
await item.get(async (doNotCache) => {
|
|
20
|
+
// On the first try
|
|
21
|
+
if (fail) {
|
|
22
|
+
fail = false
|
|
23
|
+
doNotCache(true)
|
|
24
|
+
throw new Error("expected failure")
|
|
25
|
+
} else {
|
|
26
|
+
doNotCache(false)
|
|
27
|
+
return true
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
30
|
+
).toBe(true)
|
|
31
|
+
})
|
|
32
|
+
})
|
package/src/cache/item.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Redis } from "ioredis"
|
|
|
2
2
|
import * as zlib from "zlib"
|
|
3
3
|
import { promisify } from "util"
|
|
4
4
|
import type { CacheType } from "./types"
|
|
5
|
+
import * as Sentry from "@sentry/node"
|
|
5
6
|
export { CacheType } from "./types"
|
|
6
7
|
|
|
7
8
|
const compress = promisify(zlib.gzip)
|
|
@@ -77,9 +78,10 @@ class CacheItem {
|
|
|
77
78
|
}
|
|
78
79
|
return data
|
|
79
80
|
}
|
|
80
|
-
} catch {
|
|
81
|
+
} catch (err) {
|
|
82
|
+
Sentry.captureException(err)
|
|
81
83
|
// Keep going as though we had a cache miss if there is a problem but don't cache it
|
|
82
|
-
return miss()
|
|
84
|
+
return miss((_doNotCache: boolean) => {})
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
87
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import passport from "passport"
|
|
2
2
|
import User from "../../models/user"
|
|
3
3
|
import { parsedJwtFromRequest } from "./jwt"
|
|
4
|
+
import * as Sentry from "@sentry/node"
|
|
4
5
|
|
|
5
6
|
export const requestAuth = passport.authenticate("orcid", {
|
|
6
7
|
session: false,
|
|
@@ -9,6 +10,7 @@ export const requestAuth = passport.authenticate("orcid", {
|
|
|
9
10
|
export const authCallback = (req, res, next) =>
|
|
10
11
|
passport.authenticate("orcid", (err, user) => {
|
|
11
12
|
if (err) {
|
|
13
|
+
Sentry.captureException(err)
|
|
12
14
|
if (err.type) {
|
|
13
15
|
return res.redirect(`/error/orcid/${err.type}`)
|
|
14
16
|
} else {
|
package/src/libs/orcid.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import request from "request"
|
|
3
3
|
import xmldoc from "xmldoc"
|
|
4
4
|
import config from "../config"
|
|
5
|
+
import * as Sentry from "@sentry/node"
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
getProfile(token) {
|
|
@@ -20,6 +21,7 @@ export default {
|
|
|
20
21
|
},
|
|
21
22
|
(err, res) => {
|
|
22
23
|
if (err) {
|
|
24
|
+
Sentry.captureException(err)
|
|
23
25
|
reject({
|
|
24
26
|
message:
|
|
25
27
|
"An unexpected ORCID login failure occurred, please try again later.",
|