File tree 2 files changed +11
-5
lines changed
2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import { TenantConnection } from '@internal/database'
33
33
import { S3Store } from '@tus/s3-store'
34
34
import { Upload } from '@aws-sdk/lib-storage'
35
35
import { StreamSplitter } from '@tus/server'
36
+ import { PgLock } from '@storage/protocols/tus'
36
37
37
38
const tracingEnabled = process . env . TRACING_ENABLED === 'true'
38
39
const headersEnv = process . env . OTEL_EXPORTER_OTLP_TRACES_HEADERS || ''
@@ -259,6 +260,11 @@ const sdk = new NodeSDK({
259
260
} ,
260
261
} ,
261
262
} ) ,
263
+ new ClassInstrumentation ( {
264
+ targetClass : PgLock ,
265
+ enabled : true ,
266
+ methodsToInstrument : [ 'lock' , 'unlock' , 'acquireLock' ] ,
267
+ } ) ,
262
268
new ClassInstrumentation ( {
263
269
targetClass : S3Client ,
264
270
enabled : true ,
Original file line number Diff line number Diff line change 1
1
import { Lock , Locker , RequestRelease } from '@tus/server'
2
- import { clearTimeout } from 'timers'
3
- import EventEmitter from 'events'
4
- import { Database , DBError } from '../../database'
2
+ import { clearTimeout } from 'node: timers'
3
+ import EventEmitter from 'node: events'
4
+ import { Database } from '../../database'
5
5
import { PubSubAdapter } from '@internal/pubsub'
6
6
import { UploadId } from './upload-id'
7
- import { ERRORS } from '@internal/errors'
7
+ import { ErrorCode , ERRORS , StorageBackendError } from '@internal/errors'
8
8
9
9
const REQUEST_LOCK_RELEASE_MESSAGE = 'REQUEST_LOCK_RELEASE'
10
10
@@ -94,7 +94,7 @@ export class PgLock implements Lock {
94
94
await db . mustLockObject ( uploadId . bucket , uploadId . objectName , uploadId . version )
95
95
return true
96
96
} catch ( e ) {
97
- if ( e instanceof DBError && e . message === 'resource_locked' ) {
97
+ if ( e instanceof StorageBackendError && e . code === ErrorCode . ResourceLocked ) {
98
98
await this . notifier . release ( id )
99
99
await new Promise ( ( resolve ) => {
100
100
setTimeout ( resolve , 500 )
You can’t perform that action at this time.
0 commit comments