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

supabase / storage / 26899901438

03 Jun 2026 04:55PM UTC coverage: 42.425% (-33.0%) from 75.379%
26899901438

Pull #1132

github

web-flow
Merge 9c68b15ac into 0afb09325
Pull Request #1132: fix: add acceptance matrix for vectors

2460 of 6402 branches covered (38.43%)

Branch coverage included in aggregate %.

257 of 446 new or added lines in 27 files covered. (57.62%)

3664 existing lines in 167 files now uncovered.

4857 of 10845 relevant lines covered (44.79%)

34.27 hits per line

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

67.92
/src/http/error-handler.ts
1
import { FastifyError } from '@fastify/error'
2
import {
3
  ErrorCode,
4
  getErrorCode,
5
  isRenderableError,
6
  StorageBackendError,
7
  StorageError,
8
} from '@internal/errors'
9
import { isDatabaseSlowDownError } from '@internal/errors/database-error'
10
import { FastifyInstance } from 'fastify'
11

12
/**
13
 * The global error handler for all the uncaught exceptions within a request.
14
 * We try our best to display meaningful information to our users
15
 * and log any error that occurs
16
 * @param app
17
 * @param options
18
 */
19
export const setErrorHandler = (
4✔
20
  app: FastifyInstance,
21
  options?: {
22
    respectStatusCode?: boolean
23
    formatter?: (error: StorageError) => Record<string, unknown>
24
  }
25
) => {
26
  app.setErrorHandler<Error>(function (error, request, reply) {
10✔
27
    const formatter = options?.formatter || ((e) => e)
5✔
28
    // We assign the error received.
29
    // it will be logged in the request log plugin
30
    request.executionError = error
5✔
31

32
    // database error
33
    if (isDatabaseSlowDownError(error)) {
5!
34
      return reply.status(429).send(
×
35
        formatter({
36
          statusCode: `429`,
37
          error: 'too_many_connections',
38
          code: ErrorCode.SlowDown,
39
          message: 'Too many connections issued to the database',
40
        })
41
      )
42
    }
43

44
    if (isRenderableError(error)) {
5✔
45
      const renderableError = error.render()
4✔
46
      const statusCode = options?.respectStatusCode
4!
47
        ? parseInt(renderableError.statusCode, 10)
48
        : error.userStatusCode
4!
49
          ? error.userStatusCode
50
          : renderableError.statusCode === '500'
×
51
            ? 500
52
            : 400
53

54
      if (
4✔
55
        renderableError.code === ErrorCode.AbortedTerminate ||
12✔
56
        (error instanceof StorageBackendError && error.shouldCloseConnection())
57
      ) {
58
        reply.header('Connection', 'close')
1✔
59

60
        reply.raw.once('finish', () => {
1✔
61
          setTimeout(() => {
1✔
62
            if (!request.raw.closed) {
×
63
              request.raw.destroy()
×
64
            }
65
          }, 3000)
66
        })
67
      }
68

69
      return reply.status(statusCode).send(
4✔
70
        formatter({
71
          ...renderableError,
72
          error: error.error || renderableError.code,
4!
73
        })
74
      )
75
    }
76

77
    // Fastify errors
78
    if ('statusCode' in error) {
1!
79
      const err = error as FastifyError
1✔
80

81
      if (err.code === 'FST_ERR_CTP_INVALID_MEDIA_TYPE') {
1!
UNCOV
82
        return reply.status(400).send(
×
83
          formatter({
84
            statusCode: '415',
85
            code: ErrorCode.InvalidMimeType,
86
            error: 'invalid_mime_type',
87
            message: 'Invalid Content-Type header',
88
          })
89
        )
90
      }
91

92
      const errorCode = getErrorCode(err)
1✔
93
      const responseErrorCode = (
94
        errorCode === ErrorCode.UnknownError ? ErrorCode.InternalError : errorCode
1!
95
      ) as ErrorCode
96

97
      return reply.status(err.statusCode || 500).send(
1!
98
        formatter({
99
          statusCode: `${err.statusCode}`,
100
          error: err.name,
101
          code: responseErrorCode,
102
          message: err.message,
103
        })
104
      )
105
    }
106

UNCOV
107
    return reply.status(500).send(
×
108
      formatter({
109
        statusCode: '500',
110
        error: 'Internal',
111
        message: 'Internal Server Error',
112
        code: ErrorCode.InternalError,
113
      })
114
    )
115
  })
116
}
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