dart_spawner 1.3.0
dart_spawner: ^1.3.0 copied to clipboard
Runs a Dart script/File/Uri inside a new Isolate of the current Dart VM. It also can spawn a Dart File from another Dart project/package into the current Dart VM.
1.3.0 #
DartSpawner:spawnDartURI(andspawnDartwith aUri): a relative fileUri(no scheme, e.g.Uri.file('bin/main.dart')orUri.parse('bin/main.dart')) is now resolved against the working directory.Isolate.spawnUriresolved it against the current isolate's script URI.file:,package:,http(s):,data:and absolute URIs are used as they are.- Added
resolveRelativeFileUri.
SpawnedIsolate:- Fix the exit detection with the VM service enabled (always the case
under
dart test --coverage): an isolate that didn't answer anIsolate.pingwithinisolateCheckPingTimeout(2s), for example a script blocking its event loop or a loaded machine, was taken as exited andexitCodecompleted with0while it was still running.- The
onExit/onErrorisolate ports are the source of truth for the exit. - An isolate paused at exit (
--pause-isolates-on-exit, which delaysonExit) is now detected through the VM servicegetIsolateRPC (aPauseExitpause event). A failed or timed out request is never taken as an exit. isolateCheckPingTimeoutis now the timeout of that request.
- The
stop: returnsfalse(without stopping again) when anotherstopis in progress, or when the isolate exits while it's starting.
- Fix the exit detection with the VM service enabled (always the case
under
DartProject:runProcess/runDartVM: addeddrainOutput(defaultfalse), to consume and discard the processstdout/stderr. WithoutcatchOutput,redirectOutputordrainOutputthe output is still not consumed (the caller may read it), and a process that writes more than the OS pipe buffer blocks.
- Tests:
- Relative
Urispawned from another working directory. - A script blocking its event loop for longer than
isolateCheckPingTimeoutwith the VM service enabled (with and without--pause-isolates-on-exit, plain and managed): not reported as exited. drainOutputwith a 1 MiB child output.
- Relative
1.2.2 #
- async_extension: ^1.2.24
1.2.1 #
DartSpawner:spawnDartFile(andspawnDartwith aFileor a file path): fix relative paths, whichIsolate.spawnUriresolved against the current isolate's script URI instead of the working directory. The file is now resolved withFile.absolute.
ProcessInfo:exitCode: when the output is caught or redirected, also wait (up to 5s after the exit) forstdout/stderrto be consumed, sooutputanderrorOutputare complete once it completes. Previously they could still be empty right afterexitCodecompleted.
DartProject:runDartPubGet: drain thepub getoutput (an undrained process that prints more than the OS pipe buffer never exits) and include it in theStateErrorthrown on failure.runProcess: document that, withoutcatchOutput/redirectOutput, the caller must drainProcessInfo.processstdout/stderr.
- Tests:
spawnedMainprotocol tests in the test's own isolate group (so they are visible todart test --coverage, which only collects that group).- Integration tests: arguments, a lot of output, self-terminated isolates,
concurrent spawns, the same file twice, relative/absolute paths, relative
project directory,
package:URIs, stop right after spawn, observatory, managed stop timeout and managed scripts exiting withoutstopped. - A separate-VM runner (
test/fixtures/spawner_runner.dart) for theDART_SPAWNER_*environment variables, SIGINT/SIGTERM handling, non-zero exit codes, argument passing and process output draining. test/test_project: Dart 3 SDK constraint (^3.13.0) andxml: ^7.1.0.
1.2.0 #
-
DartSpawner:- Honour the
startupTimeoutconstructor parameter (it was ignored), and use it for the managed (usesSpawnedMain) startup instead of a fixed 45s. - An uncaught error in the spawned isolate now completes
exitCodewithuncaughtErrorExitCode(255, as thedartcommand) instead of0. The error is available atuncaughtError(aRemoteError). - A failure to spawn (
IsolateSpawnException, startup timeout, managed script exiting before callingspawnedMain) closes the isolate ports, kills the isolate, completesexitCodewith 255 and is available atspawnError. - Managed scripts:
exitCodealso completes when the isolate exits without reportingstopped;SpawnedIsolate.stopwaits for the script'sstopcallback (up tomanagedStopTimeout) and then kills the isolate. - Fix the Dart VM detection, which rejected VM service protocol versions
with a
0minor version.
- Honour the
-
DartProject:- Added
projectResolutionDirectory: supports pub workspace members (resolution: workspace), resolvingprojectPackageConfigUriandprojectPubspecLockFileat the workspace root. existsProjectPackageConfigUri: returnfalse(instead of throwing) when the project directory is resolved asynchronously.
- Added
-
SpawnedIsolate: fix a concurrent modification error whenstopis called after the isolate finished. -
Tests: unit tests for the tools, extensions and
DartProject; integration tests spawning scripts,Files andUris, error propagation, managed scripts, a separate project and a pub workspace member. -
Dart CI:
actions/checkout@v7,codecov/codecov-action@v7. -
sdk: ^3.13.0
-
path: ^1.9.1
-
yaml: ^3.1.4
-
async_extension: ^1.2.23
-
lints: ^6.1.0
-
test: ^1.33.0
-
dependency_validator: ^5.1.0
-
coverage: ^1.16.0
1.1.0 #
-
Dart CI: update and optimize jobs.
-
sdk: '>=3.0.0 <4.0.0'
-
path: ^1.8.3
-
yaml: ^3.1.2
-
async_extension: ^1.2.4
-
lints: ^2.1.1
-
test: ^1.24.6
-
dependency_validator: ^3.2.2
-
coverage: ^1.6.3
1.0.6 #
- Added environment variable:
- DART_SPAWNER_DEBUG
- DART_SPAWNER_STARTUP_TIMEOUT
- DART_SPAWNER_ISOLATE_CHECK_PING_TIMEOUT
1.0.5 #
- Renamed
runCommandtorunProcess.- Returns a
ProcessInfo.
- Returns a
- Added
runDartVM, to start a new Dart VM.
1.0.4 #
DartProject.cleanDartPubGetGeneratedFiles:- Fix
deleteDirectory.
- Fix
1.0.3 #
projectPackageConfigUri:- Return
.dart_tool/package_config.json, since.packagesis deprecated.
- Return
- Added
runDartPubGet,ensureProjectDependenciesResolved,existsProjectPackageConfigUriandcleanDartPubGetGeneratedFiles. - Improve tests:
- Test spawn of file in a different project (
test/test_project), with different dependencies.
- Test spawn of file in a different project (
- Change package
pedantic(deprecated) tolints. - lints: ^1.0.1
1.0.2 #
- Improved
spawnedMainconsole logging.
1.0.1 #
- Adjust package description.
- Adjust
README.md.- Added
codecov.iobadge.
- Added
1.0.0 #
- Support to spawn Dart entry points: script, file and Uri.
- Allow the use of another project/package dependencies while running a spawned Dart entry point.
- Added code coverage.
- Initial version.