• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / storage / 28793654629

06 Jul 2026 01:05PM UTC coverage: 48.793% (-30.2%) from 79.041%
28793654629

Pull #1206

github

web-flow
Merge 056d0b5f9 into d54b900bf
Pull Request #1206: fix: leak of request into pools

3210 of 7101 branches covered (45.2%)

Branch coverage included in aggregate %.

2 of 2 new or added lines in 2 files covered. (100.0%)

3858 existing lines in 164 files now uncovered.

6208 of 12201 relevant lines covered (50.88%)

63.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/src/http/plugins/storage.ts
1
import { createStorageBackend, StorageBackendAdapter } from '@storage/backend'
2
import { CdnCacheManager } from '@storage/cdn/cdn-cache-manager'
3
import type { Database } from '@storage/database'
4
import { StoragePgDB } from '@storage/database'
5
import { PassThroughLocation, TenantLocation } from '@storage/locator'
6
import { Storage } from '@storage/storage'
7
import fastifyPlugin from 'fastify-plugin'
8
import { getConfig } from '../../config'
9

10
declare module 'fastify' {
11
  interface FastifyRequest {
12
    storage: Storage
13
    backend: StorageBackendAdapter
14
    cdnCache: CdnCacheManager
15
  }
16
}
17

18
const { storageBackendType, storageS3Bucket } = getConfig()
3✔
19

20
const storageBackend = createStorageBackend(storageBackendType)
3✔
21

22
// TenantLocation is immutable so singleton not to allocate per request.
23
const tenantLocation = new TenantLocation(storageS3Bucket)
3✔
24

25
export const storage = fastifyPlugin(
3✔
26
  async function storagePlugin(fastify) {
27
    fastify.decorateRequest('storage')
4✔
28
    fastify.addHook('preHandler', async (request) => {
4✔
UNCOV
29
      const databaseOptions = {
×
30
        tenantId: request.tenantId,
31
        host: request.headers['x-forwarded-host'] as string,
32
        reqId: request.id,
33
        sbReqId: request.sbReqId,
34
        latestMigration: request.latestMigration,
35
      }
36

UNCOV
37
      const database: Database = new StoragePgDB(request.db, databaseOptions)
×
38

UNCOV
39
      const location = request.isIcebergBucket
×
40
        ? new PassThroughLocation(request.internalIcebergBucketName!)
41
        : tenantLocation
42

UNCOV
43
      request.backend = storageBackend
×
UNCOV
44
      request.storage = new Storage(storageBackend, database, location)
×
UNCOV
45
      request.cdnCache = new CdnCacheManager(request.storage)
×
46
    })
47

48
    fastify.addHook('onClose', async () => {
4✔
49
      storageBackend.close()
4✔
50
    })
51
  },
52
  { name: 'storage-init' }
53
)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc