@prisma/engine-core
Advanced tools
Comparing version 0.0.31 to 0.0.32
@@ -51,2 +51,3 @@ /// <reference types="node" /> | ||
start(): Promise<void>; | ||
fail: (e: any, why: any) => void; | ||
/** | ||
@@ -53,0 +54,0 @@ * If Prisma runs, stop it |
@@ -31,6 +31,6 @@ "use strict"; | ||
const cross_fetch_1 = __importDefault(require("cross-fetch")); | ||
const getInternalDatamodelJson_1 = require("./getInternalDatamodelJson"); | ||
const Engine_1 = require("./Engine"); | ||
const debug = debug_1.default('engine'); | ||
const readFile = util_1.promisify(fs.readFile); | ||
const exists = util_1.promisify(fs.exists); | ||
/** | ||
@@ -50,2 +50,6 @@ * Node.js based wrapper to run the Prisma binary | ||
this.errorLogs = ''; | ||
this.fail = (e, why) => { | ||
debug(e, why); | ||
this.stop(); | ||
}; | ||
/** | ||
@@ -79,2 +83,5 @@ * If Prisma runs, stop it | ||
async getPrismaYml(ymlPath) { | ||
if (!exists(ymlPath)) { | ||
return undefined; | ||
} | ||
return await readFile(ymlPath, 'utf-8'); | ||
@@ -94,7 +101,7 @@ } | ||
const schemaEnv = {}; | ||
if (!this.datamodelJson) { | ||
this.datamodelJson = await getInternalDatamodelJson_1.getInternalDatamodelJson(this.datamodel, this.schemaInferrerPath); | ||
} | ||
debug(`Starting binary at ${this.prismaPath}`); | ||
const env = Object.assign({ PRISMA_CONFIG, PRISMA_SDL: this.datamodel, PRISMA_DML: '', SERVER_ROOT: process.cwd(), PRISMA_INTERNAL_DATA_MODEL_JSON: this.datamodelJson }, schemaEnv); | ||
const env = { | ||
PRISMA_CONFIG, | ||
PRISMA_DML: this.datamodel, | ||
}; | ||
debug(env); | ||
@@ -121,13 +128,10 @@ this.child = child_process_1.spawn(this.prismaPath, [], { | ||
if (code !== 0 && !this.exiting) { | ||
const debugString = this.debug | ||
? '' | ||
: 'Please enable "debug": true in the Engine constructor to get more insights.'; | ||
throw new Error(`Child exited with code ${code}${debugString}${e}`); | ||
throw new Engine_1.PhotonError(`Error in query engine: ` + this.errorLogs, undefined, undefined, this.errorLogs); | ||
} | ||
}); | ||
// Make sure we kill Rust when this process is being killed | ||
process.once('SIGTERM', this.stop); | ||
process.once('SIGINT', this.stop); | ||
process.once('uncaughtException', this.stop); | ||
process.once('unhandledRejection', this.stop); | ||
process.once('SIGTERM', e => this.fail(e, 'SIGTERM')); | ||
process.once('SIGINT', e => this.fail(e, 'SIGINT')); | ||
// process.once('uncaughtException', e => this.fail(e, 'uncaughtException')) | ||
// process.once('unhandledRejection', e => this.fail(e, 'unhandledRejection')) | ||
await this.engineReady(); | ||
@@ -187,3 +191,3 @@ const url = `http://localhost:${this.port}`; | ||
debug(e.message); | ||
if (tries >= 100) { | ||
if (tries >= 10) { | ||
throw e; | ||
@@ -250,3 +254,3 @@ } | ||
const stringified = errors ? JSON.stringify(errors, null, 2) : null; | ||
const message = stringified.length > 0 ? stringified : `Error in prisma.\$\{rootField || 'query'}`; | ||
const message = stringified.length > 0 ? stringified : `Error in photon.\$\{rootField || 'query'}`; | ||
const isPanicked = this.errorLogs.includes('panicked'); | ||
@@ -253,0 +257,0 @@ if (isPanicked) { |
{ | ||
"name": "@prisma/engine-core", | ||
"version": "0.0.31", | ||
"version": "0.0.32", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
648
38778