Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk): improved error reporting by adding detail to getConfig and…
… getDmmf error (#13736) * sdk: improved error reporting by adding detail to getConfig and getDmmf error * sdk: added openssl fix proposal * sdk: added comments to errorHelpers * sdk: updated structured error output in getDmmf * sdk: updated structured error output in getConfig * ci: fix tests * sdk: add tests for loadNodeAPILibrary * Update packages/sdk/src/engine-commands/getConfig.ts Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com> * Update packages/sdk/src/engine-commands/getConfig.ts Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com> * Update packages/sdk/src/engine-commands/getDmmf.ts Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com> * Update packages/sdk/src/engine-commands/getDmmf.ts Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com> * ci: fix tests for getDmmf * ci: fix tests * ci: fix tests * ci: fix tests * ci: fix tests * ci: fix tests * ci: fixed getConfig tests * chore: simplified query-engine test assertions * chore: fix typo * fix: tests * internals: updated openssl error message * Update packages/internals/src/__tests__/engine-commands/queryEngineCommons.test.ts Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com> Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>
- Loading branch information
Showing
22 changed files
with
354 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/client/src/__tests__/integration/__helpers__/migrateDb.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
packages/internals/src/__tests__/engine-commands/queryEngineCommons.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { BinaryType } from '@prisma/fetch-engine' | ||
import * as E from 'fp-ts/Either' | ||
|
||
import { loadNodeAPILibrary } from '../../engine-commands/queryEngineCommons' | ||
import { resolveBinary } from '../../resolveBinary' | ||
import * as loadUtils from '../../utils/load' | ||
|
||
const describeIf = (condition: boolean) => (condition ? describe : describe.skip) | ||
|
||
describeIf(process.env.PRISMA_CLI_QUERY_ENGINE_TYPE !== 'binary')('loadNodeAPILibrary', () => { | ||
it('error path', async () => { | ||
const spyLoadTag = 'error-load' | ||
const spyLoad = jest.spyOn(loadUtils, 'load').mockImplementation((id: string) => { | ||
throw new Error(spyLoadTag) | ||
}) | ||
|
||
try { | ||
const queryEnginePath = await resolveBinary(BinaryType.libqueryEngine) | ||
const result = await loadNodeAPILibrary(queryEnginePath)() | ||
|
||
expect(E.isLeft(result)).toBe(true) | ||
|
||
if (E.isLeft(result)) { | ||
expect(result.left.type).toEqual('connection-error') | ||
expect(result.left.reason).toEqual('Unable to establish a connection to query-engine-node-api library.') | ||
expect(result.left.error).toBeTruthy() | ||
} | ||
} finally { | ||
spyLoad.mockRestore() | ||
} | ||
}) | ||
|
||
it('error path, openssl', async () => { | ||
const spyLoadTag = 'error-load, something something openssl installation' | ||
const spyLoad = jest.spyOn(loadUtils, 'load').mockImplementation((id: string) => { | ||
throw new Error(spyLoadTag) | ||
}) | ||
|
||
try { | ||
const queryEnginePath = await resolveBinary(BinaryType.libqueryEngine) | ||
const result = await loadNodeAPILibrary(queryEnginePath)() | ||
|
||
expect(E.isLeft(result)).toBe(true) | ||
|
||
if (E.isLeft(result)) { | ||
expect(result.left.type).toEqual('connection-error') | ||
expect(result.left.reason).toEqual( | ||
`Unable to establish a connection to query-engine-node-api library. It seems there is a problem with your OpenSSL installation!`, | ||
) | ||
expect(result.left.error).toBeTruthy() | ||
} | ||
} finally { | ||
spyLoad.mockRestore() | ||
} | ||
}) | ||
|
||
it('happy path', async () => { | ||
const queryEnginePath = await resolveBinary(BinaryType.libqueryEngine) | ||
const result = await loadNodeAPILibrary(queryEnginePath)() | ||
|
||
expect(E.isRight(result)).toBe(true) | ||
|
||
if (E.isRight(result)) { | ||
expect(result.right.NodeAPIQueryEngineLibrary).toBeTruthy() | ||
expect(result.right.NodeAPIQueryEngineLibrary.QueryEngine).toBeTruthy() | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.