Skip to content

Commit

Permalink
opt out of assembly validation by default
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainMuller committed Jul 24, 2023
1 parent d5ae229 commit 4b6dac1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/@jsii/kernel/src/kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export class Kernel {
* Set to true for timing data to be emitted.
*/
public debugTimingEnabled = false;
/**
* Set to true to validate assemblies upon loading (slow).
*/
public validateAssemblies = false;

readonly #assemblies = new Map<string, Assembly>();
readonly #objects = new ObjectTable(this.#typeInfoForFqn.bind(this));
Expand Down Expand Up @@ -151,7 +155,7 @@ export class Kernel {
let assmSpec: spec.Assembly;
try {
assmSpec = this.#debugTime(
() => spec.loadAssemblyFromPath(packageDir),
() => spec.loadAssemblyFromPath(packageDir, this.validateAssemblies),
`loadAssemblyFromPath(${packageDir})`,
);
} catch (e: any) {
Expand Down
2 changes: 2 additions & 0 deletions packages/@jsii/runtime/lib/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ export class KernelHost {
debug?: boolean;
debugTiming?: boolean;
noStack?: boolean;
validateAssemblies?: boolean;
} = {},
) {
this.kernel.traceEnabled = opts.debug ?? false;
this.kernel.debugTimingEnabled = opts.debugTiming ?? false;
this.kernel.validateAssemblies = opts.validateAssemblies ?? false;
}

public run() {
Expand Down
8 changes: 7 additions & 1 deletion packages/@jsii/runtime/lib/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const version = packageInfo.version;
const noStack = !!process.env.JSII_NOSTACK;
const debug = !!process.env.JSII_DEBUG;
const debugTiming = !!process.env.JSII_DEBUG_TIMING;
const validateAssemblies = !!process.env.JSII_VALIDATE_ASSEMBLIES;

// This assumes FD#3 is opened for reading and writing. This is normally
// performed by`bin/jsii-runtime.js`, and we will not be verifying this once
Expand All @@ -25,7 +26,12 @@ const stdio = new SyncStdio({
});

const inout = new InputOutput(stdio);
const host = new KernelHost(inout, { debug, noStack, debugTiming });
const host = new KernelHost(inout, {
debug,
noStack,
debugTiming,
validateAssemblies,
});

host.once('exit', process.exit.bind(process));

Expand Down

0 comments on commit 4b6dac1

Please sign in to comment.