Skip to content

Conversation

@kim
Copy link
Contributor

@kim kim commented May 8, 2025

Modules generally don't honor the workspace cargo lock file, so may upgrade ahash silently, which pulls in a getrandom version that is not the one pulled in via binding. Thus feature unification doesn't apply and modules fail to compile due to the wasm target not being supported by the transitive getrandom.

This also causes smoketests to fail.

Expected complexity level and risk

1

Testing

Smoketests / module compilation fail before this change, and succeed after.

Modules generally don't honor the workspace cargo lock file, so may
upgrade `ahash` silently, which pulls in a `getrandom` version that is
not the one pulled in via `binding`. Thus feature unification doesn't
apply and modules fail to compile due to the wasm target not being
supported by the transitive `getrandom`.

This also causes smoketests to fail.
@kim kim requested review from Centril and coolreader18 May 8, 2025 11:47
@kim
Copy link
Contributor Author

kim commented May 8, 2025

Conceivably, this can happen again if we have some other crate that transitively depends on getrandom. Maybe there is a more robust way to enforce a single version of getrandom?

@kim kim added the bugfix Fixes something that was expected to work differently label May 8, 2025
@coolreader18
Copy link
Collaborator

I think ideally in the future this kinda thing never happens again in the rust ecosystem, cause it's been a royal pain to deal with. But, also, those errors from getrandom 0.3 are actually exactly what we want - failing to compile when you pull in getrandom. So, this is the right fix.

@coolreader18
Copy link
Collaborator

Also, it seems like you unintentionally ran a full cargo update.

@kim
Copy link
Contributor Author

kim commented May 8, 2025

you unintentionally ran a full cargo update.

It was not quite unintentionally, because the actual problem here is that building a module won't honor the lock file. So making the dependency graphs match, if only for a short period of time, seems like something we should do more often.

Feel free to disagree, but I'd like to understand the reasoning.

@gefjon
Copy link
Contributor

gefjon commented May 8, 2025

It was not quite unintentionally, because the actual problem here is that building a module won't honor the lock file

Can we (in a separate PR) add a flag to spacetime build and friends which makes it reflect the lockfile? Or possibly just a way to pass cargo flags through more generally?

@kim
Copy link
Contributor Author

kim commented May 8, 2025

Can we (in a separate PR) add a flag to spacetime build and friends which makes it reflect the lockfile?

No I don't think: a module has spacetimedb in its dependencies, which is what pulled in the faulty dependency graph. I'm not aware of a way to force a dependency to lock its dependencies transitively.

What we might want to consider is to somehow make the tests that compile modules/module-test not honor the lockfile, so we'll catch this earlier and in a more obvious way. I'm not sure this can actually be done except for removing the lockfile.

@gefjon
Copy link
Contributor

gefjon commented May 8, 2025

Wait, what? Surely if you compile your module with --locked, that makes it respect the lockfile for the entire tree of dependencies including transitive deps, right?

@kim
Copy link
Contributor Author

kim commented May 8, 2025

If I create a fresh module, it won't have a Cargo.lock file and will go out to the internet to resolve the dependencies. It won't, for a particular dependency, get the lock file of that dependency and consider it for version constraints.

Smoketests create fresh modules all the time, and they are built outside the workspace, so that's why they are failing.

@gefjon
Copy link
Contributor

gefjon commented May 8, 2025

Ah, I see. Yes, that's unfortunate.

@Centril
Copy link
Contributor

Centril commented May 8, 2025

Looks like @coolreader18 and @gefjon got the review handled so no further input from me :)

@kim
Copy link
Contributor Author

kim commented May 8, 2025

Someone press the button then? 😇

@kim kim added this pull request to the merge queue May 8, 2025
Merged via the queue into master with commit a056796 May 8, 2025
29 of 30 checks passed
@kim kim deleted the kim/prevent-getrandom03 branch May 8, 2025 15:00
kim added a commit that referenced this pull request May 8, 2025
Make sure the `Cargo.lock` file of the `wasm_bindings` job reflects the
latest available versions. This is what users would end up with on a
fresh module, so we want to catch any compile errors arising from a
different transitive closure of dependencies than what is in the
workspace lock file.

Follup-up for: #2714
gefjon pushed a commit that referenced this pull request May 9, 2025
Conflicts:
	Cargo.lock

It looks like you may be committing a cherry-pick.
If this is not correct, please run
	git update-ref -d CHERRY_PICK_HEAD
and try again.

Author:    Kim Altintop <kim@eagain.io>
Date:      Thu May 8 16:33:58 2025 +0200

On branch phoebe/release-v1.1.2
You are currently cherry-picking commit a056796.

Changes to be committed:
	modified:   Cargo.lock
	modified:   Cargo.toml
	modified:   crates/bindings/tests/snapshots/deps__spacetimedb_bindings_dependencies.snap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes something that was expected to work differently

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants