Skip to content

Pub is not able to handle out-of-date snapshots #33577

@munificent

Description

@munificent

Pub global activate was broken when the VM flipped to Dart 2 by default. I'm working on fixing that. In the process, I stumbled into an important behavior that I believe used to work in the Dart 1 VM but does not any more. Let's say the user does this:

  1. They run pub get. That downloads some packages and precompiles their binaries to snapshots so that they can be run faster.

  2. Later, they upgrade to a new version of the Dart SDK. That version has a VM with a newer snapshot version.

  3. They pub run one of the executables. This tries to run the old snapshot generated in step 1 on the newer VM.

In Dart 1, at step 3, pub would catch an IsolateSpawnException and look for message "Wrong script snapshot version". If found, it would discard the old snapshot and generate a new one for the current VM, and then proceed merrily along its way.

In Dart 2, it looks like the VM hard aborts the entire process if you load an old snapshot. There's no way that pub can catch the error because it's not a thrown exception. The process just dies. At least I think that's what's going on.

Am I understanding the current behavior right? If so, how can pub detect an outdated snapshot and handle this case?

If we don't fix this soon, then the next time the VM revs the snapshot version, every user who has used pub run (which is basically everyone, because of pub run test) or pub global activate since the switch to Dart 2 by default is going to blow up the next time they try to run one of those commands.

Metadata

Metadata

Assignees

Labels

P1A high priority bug; for example, a single project is unusable or has many test failuresarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions