-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Map error positions against the original source (sourcemapping) (#848)
* compiler: generate a source map if a job name is passed * runtime: add a position mapping function * runtime: map error position * runtime: update test * comment * runtime: properly map positions and stack traces in errors * compiler: more tests * cli: refactor to build sourcemaps up properly * lexicon: updated typings * runtime: nicely log errors with position and line of code * runtime: tidy up * runtime: rewrite sourcemap tests and improve typings * runtime: fix tests * runtime: ensure a sourcemap is set when a workflow is generated from a string expression * tests: add tests for error types Not sure how useful this is tbh * runtime: typing * engine: adjust to new compiler API * changesets * runtime: update test * format * runtime: refine error output * tests: added error logging tests * Sourcemapping adaptor errors (#851) * runtime: refine error output * tests: added error logging tests * compiler: append positional information to top level operations * compiler: write the operations map to the souce map * lexicon: add typings for extended source map * lexicon: tweak sourcemap types * package lock * runtime: updat error handling to handle adaptor errors with source mapping * runtime: better handling of nested adaptor errors probably * runtime: update tests * cli: types * tidy * runtime: better handling of nested errors * Runtime: attempt to clean up error output (#852) * compiler: append positional information to top level operations * compiler: write the operations map to the souce map * lexicon: add typings for extended source map * lexicon: tweak sourcemap types * package lock * runtime: updat error handling to handle adaptor errors with source mapping * runtime: better handling of nested adaptor errors probably * runtime: update tests * cli: types * tidy * runtime: better handling of nested errors * runtime: improvements to reporting of errors * changeset * runtime: improve error details * runtime: better frame detection for adaptor errors * runtime: fix tests * tests: update output logs * logger: ensure timestamp is added to print logs, so that the worker can handle them properly * version: [email protected] [email protected] * tmp: worker to rc1 version * fix openfnx build Make sure dist is properly cleaned each time * runtime: simplify adaptorerror constructor * tests: fix adaptor versions * cli: skip flay test * tests: skip more flaky docs tests * worker: version to 1.9.0 * cli: update changelog
- Loading branch information
1 parent
c378996
commit c9afba0
Showing
66 changed files
with
1,580 additions
and
237 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ public/ | |
!public/index.html | ||
tsconfig.tsbuildinfo | ||
ts.cache | ||
dist | ||
|
||
# Build tools | ||
.rollup.cache | ||
|
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"workflow": { | ||
"steps": [ | ||
{ | ||
"id": "ref", | ||
"adaptor": "[email protected]", | ||
"expression": "fn((state) => state.x.y)" | ||
}, | ||
{ | ||
"id": "not-function", | ||
"adaptor": "[email protected]", | ||
"expression": "fn((state) => state())" | ||
}, | ||
{ | ||
"id": "assign-const", | ||
"adaptor": "[email protected]", | ||
"expression": "fn((state) => { const x = 10; x = 20; })" | ||
} | ||
] | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "@openfn/integration-tests-execute", | ||
"private": true, | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"description": "Job execution tests", | ||
"author": "Open Function Group <[email protected]>", | ||
"license": "ISC", | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import test from 'ava'; | ||
import execute from '../src/execute'; | ||
|
||
// This tests the raw errors that come out of runtime | ||
// (or are written to state) | ||
// How those errors are serialized, displayed and emitted | ||
// is a problem for the runtime managers (which can have their own tests) | ||
|
||
test.serial('should throw a reference error', async (t) => { | ||
const state = { data: { x: 1 } }; | ||
|
||
const job = `fn((s) => x)`; | ||
|
||
// Tell the compiler not to import x from the adaptor | ||
const ignore = ['x']; | ||
|
||
let err; | ||
try { | ||
await execute(job, state, 'common', ignore); | ||
} catch (e: any) { | ||
err = e; | ||
} | ||
|
||
t.is(err.message, 'ReferenceError: x is not defined'); | ||
t.is(err.severity, 'crash'); | ||
t.is(err.step, 'job-1'); // this name is auto-generated btw | ||
t.deepEqual(err.pos, { | ||
column: 11, | ||
line: 1, | ||
src: 'fn((s) => x)', | ||
}); | ||
}); | ||
|
||
test.serial('should throw a type error', async (t) => { | ||
const state = { data: { x: 1 } }; | ||
|
||
const job = `fn((s) => s())`; | ||
|
||
// Tell the compiler not to import x from the adaptor | ||
const ignore = ['x']; | ||
|
||
const result = await execute(job, state, 'common', ignore); | ||
const err = result.errors['job-1']; | ||
t.log(err.pos); | ||
|
||
t.is(err.message, 'TypeError: s is not a function'); | ||
t.is(err.severity, 'fail'); | ||
t.is(err.step, 'job-1'); | ||
t.deepEqual(err.pos, { | ||
column: 11, | ||
line: 1, | ||
src: 'fn((s) => s())', | ||
}); | ||
}); | ||
|
||
// In http 6.4.3 this throws a type error | ||
// because the start of the error message is TypeError | ||
// In 6.5 we get a better error out | ||
// But the real question is: is AdaptorError even a useful error class? | ||
// I think it confuses people | ||
test.serial.skip('should throw an adaptor error', async (t) => { | ||
const state = { data: { x: 1 } }; | ||
|
||
const job = `fn((s) => s) | ||
get("www")`; | ||
|
||
const result = await execute(job, state, 'http'); | ||
const err = result.errors['job-1']; | ||
t.log(err); | ||
|
||
t.is(err.message, 'AdaptorError: INVALID_URL'); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "@openfn/integration-tests-worker", | ||
"private": true, | ||
"version": "1.0.72", | ||
"version": "1.0.73", | ||
"description": "Lightning WOrker integration tests", | ||
"author": "Open Function Group <[email protected]>", | ||
"license": "ISC", | ||
|
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
Oops, something went wrong.