Skip to content

feat: validate crawlee versions in Actor.init #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 23, 2024

Conversation

B4nan
Copy link
Member

@B4nan B4nan commented May 23, 2024

The SDK depends on @crawlee/core, but if the user installs an incompatible version of crawlee, they might end up with two installations of the @crawlee/core which means multiple static registers like the one for the global configuration, which breaks the integration, since the SDK will only touch the global config it sees, but it's a different one than the explicitly installed package.

Closes #237

@B4nan B4nan requested review from janbuchar and vladfrangu May 23, 2024 10:45
@github-actions github-actions bot added this to the 90th sprint - Tooling team milestone May 23, 2024
@github-actions github-actions bot added the t-tooling Issues with this label are in the ownership of the tooling team. label May 23, 2024
@vladfrangu
Copy link
Member

Why do we not just declare crawlee as a peer dependency? Would solve this, no?

The SDK depends on `@crawlee/core`, but if the user installs an incompatible version of crawlee, they might end up with two installations of the `@crawlee/core` which means multiple static registers like the one for the global configuration, which breaks the integration, since the SDK will only touch the global config it sees, but it's a different one than the explicitly installed package.

Closes #237
@B4nan B4nan force-pushed the ensure-correct-crawlee-version branch from e3d71d0 to ecdcdab Compare May 23, 2024 10:47
@B4nan
Copy link
Member Author

B4nan commented May 23, 2024

You mean declare it only as a peer instead of a real dependency? In the good old times, that would require the user to install it. Nowadays I believe different package managers do different things, as NPM just decided to install them (which is IMO nonsense in the first place), but yarn wont do that and fail. We don't want people to install both if they don't want to use crawlee.

And honestly, I would like to keep this validation even if it would help. It wont do any harm if things are set up correctly or the node modules folder is not even present. But it will catch such issues if its there.

@vladfrangu
Copy link
Member

vladfrangu commented May 23, 2024

I'm just worried about relying on fs checks for this... What if

  • the users use yarn/pnpm pnp right, no node_modules folder so no check
  • the users use pnpm (will it support the hardlinks? Probably)
  • doesn't respect that folder structure and flattens it out (like most of them do)

Specifically I'm worried that if our checks don't cover enough we'll need to patch release a few times till we get it right™️

Peer dependencies would solve some of these issues, but because the ecosystem cannot decide what the hell it wants, it's like you said, a mess. npm now automatically installs peer deps (but if you specify a different version that matches the range it won't install twice), yarn does... either nothing or something (looking at you peerDependencyMetadata), who knows about pnpm/bun.

There is also optionalDependencies but not sure if that'll do what we want either. 😢


Unrelated, but please use path.join for paths, something something windows 😄

@B4nan
Copy link
Member Author

B4nan commented May 23, 2024

doesn't respect that folder structure and flattens it out (like most of them do)

Flattening works only if the version ranges match, and then there is no problem.

I've been using similar checks for quite some time (years), and I got inspired by docusaurus doing the same (or similar) thing too. Yes, we might need to improve the logic over time, but only to make it more strict, not to fix some issues it introduces.

There is also optionalDependencies but not sure if that'll do what we want either. 😢

This is not an optional peer, its required, that's why its an actual dependency in the first place.

@vladfrangu
Copy link
Member

This is not an optional peer, its required, that's why its an actual dependency in the first place

Optionals still get installed. They're "optional" in the sense that if it fails to install it won't throw an error and abort the whole install process

@B4nan
Copy link
Member Author

B4nan commented May 23, 2024

Unrelated, but please use path.join for paths, something something windows 😄

used path.normalize, that should do the job too, right?

@B4nan
Copy link
Member Author

B4nan commented May 23, 2024

Optionals still get installed. They're "optional" in the sense that if it fails to install it won't throw an error and abort the whole install process

Well, that's the part I was referring to, NPM does that nowadays, I don't think yarn would (at least it wasn't doing that some time ago and failed instead)...

edit: uh, I got confused with this again, I keep taking about peers but we are talking optional instead... Again, its not optional dependency at all.

@vladfrangu
Copy link
Member

Unrelated, but please use path.join for paths, something something windows 😄

used path.normalize, that should do the job too, right?

I think so, yeah!

@B4nan
Copy link
Member Author

B4nan commented May 23, 2024

2bc86c7 will help with pnpm and yarn pnp

@B4nan
Copy link
Member Author

B4nan commented May 23, 2024

I will merge this in and release, worst case we can revert, but it looks all good locally and will help at least with the happy path.

@B4nan B4nan merged commit 66ff6a9 into master May 23, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t-tooling Issues with this label are in the ownership of the tooling team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warn about SDK vs crawlee version mismatch
2 participants