({
error,
cliVersion,
enginesVersion,
getDatabaseVersionSafe,
}: SendPanic)
| 23 | getDatabaseVersionSafe: (args: MigrateTypes.GetDatabaseVersionParams | undefined) => Promise<string | undefined> |
| 24 | } |
| 25 | export async function sendPanic({ |
| 26 | error, |
| 27 | cliVersion, |
| 28 | enginesVersion, |
| 29 | getDatabaseVersionSafe, |
| 30 | }: SendPanic): Promise<number> { |
| 31 | let dbVersion: string | undefined |
| 32 | if (error.area === ErrorArea.LIFT_CLI) { |
| 33 | // For a SQLite datasource configured as `file:dev.db` only schema will be defined |
| 34 | const getDatabaseVersionParams: MigrateTypes.GetDatabaseVersionParams | undefined = match({ |
| 35 | introspectionUrl: error.introspectionUrl, |
| 36 | }) |
| 37 | .with({ introspectionUrl: P.not(undefined) }, ({ introspectionUrl }) => { |
| 38 | return { |
| 39 | datasource: { |
| 40 | tag: 'ConnectionString', |
| 41 | url: introspectionUrl, |
| 42 | }, |
| 43 | } as const |
| 44 | }) |
| 45 | .otherwise(() => undefined) |
| 46 | |
| 47 | dbVersion = await getDatabaseVersionSafe(getDatabaseVersionParams) |
| 48 | } |
| 49 | |
| 50 | const migrateRequest = error.request ? JSON.stringify(error.request) : undefined |
| 51 | |
| 52 | const params: CreateErrorReportInput = { |
| 53 | area: error.area, |
| 54 | kind: ErrorKind.RUST_PANIC, |
| 55 | cliVersion, |
| 56 | binaryVersion: enginesVersion, |
| 57 | command: getCommand(), |
| 58 | jsStackTrace: stripVTControlCharacters(error.stack || error.message), |
| 59 | rustStackTrace: error.rustStack, |
| 60 | operatingSystem: `${os.arch()} ${os.platform()} ${os.release()}`, |
| 61 | platform: await getBinaryTargetForCurrentPlatform(), |
| 62 | liftRequest: migrateRequest, |
| 63 | fingerprint: await checkpoint.getSignature(), |
| 64 | sqlDump: undefined, |
| 65 | dbVersion: dbVersion, |
| 66 | } |
| 67 | |
| 68 | // Get an AWS S3 signed URL from the server, so we can upload a zip file |
| 69 | const signedUrl = await createErrorReport(params) |
| 70 | |
| 71 | // Mark the error report as completed |
| 72 | const id = await makeErrorReportCompleted(signedUrl) |
| 73 | |
| 74 | return id |
| 75 | } |
| 76 | |
| 77 | function getCommand(): string { |
| 78 | // don't send url |
no test coverage detected