Skip to content
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

[Theme] Delay watcher events until file is fully written #4806

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

frandiox
Copy link
Contributor

@frandiox frandiox commented Nov 7, 2024

WHY are these changes introduced?

A bit of a shot in the dark but might help in #4764

Tailwind seems to be clearing the output file first, then building its CSS, then writing the actual output content. In this scenario, we'd be emitting an event for the empty file first, then another one every time the file is written (could be in multiple chunks, unsure). Perhaps the latter events are lost or throttled down the line.

WHAT is this pull request doing?

This delays the watcher events until a safe period of time passes without file size changes. It delays all events, but it's a short period that might not be very noticeable.

The alternative would be adding some sort of debouncing logic before calling bulkUploadThemeAssets, or canceling in-flight fetch calls and sending new again as they come. These approaches seemed more complex that delaying the watcher events directly.

If the current solutions works in #4764, we might want to set a sensible default (e.g. 400ms) or introduce a flag / env variable to customize this for situations where there are big files.

How to test your changes?

Post-release steps

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@frandiox
Copy link
Contributor Author

frandiox commented Nov 7, 2024

/snapit

Copy link
Contributor

github-actions bot commented Nov 7, 2024

🫰✨ Thanks @frandiox! Your snapshot has been published to npm.

Test the snapshot by intalling your package globally:

pnpm i -g @shopify/[email protected]

After installing, validate the version by running just shopify in your terminal
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

Copy link
Contributor

github-actions bot commented Nov 7, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
72.08% (+0.01% 🔼)
8364/11603
🟡 Branches
68.56% (+0.02% 🔼)
4054/5913
🟡 Functions 71.38% 2195/3075
🟡 Lines
72.45% (+0.01% 🔼)
7908/10915

Test suite run success

1894 tests passing in 866 suites.

Report generated by 🧪jest coverage report action from df469f1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant