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

Implement sass --embedded in pure JS mode #2413

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ntkme
Copy link
Contributor

@ntkme ntkme commented Oct 26, 2024

Closes #2325.

sass/embedded-host-node#344

Implementation

The actual isolate dispatcher and compilation dispatcher are nearly unchanged. However, I had to replace isolate with worker communication, and mock tons of small things that do not work on node.

Testing

  • All Dart embedded tests are passing. - GitHub CI has been updated to run these in this PR.
  • All JS API tests are passing. - GitHub CI has been updated to run these in this PR.
  • All Ruby API tests are passing.

@ntkme ntkme marked this pull request as ready for review October 26, 2024 02:50
@ntkme ntkme marked this pull request as draft October 26, 2024 03:40
@ntkme ntkme force-pushed the embedded-compiler branch 2 times, most recently from e66df5b to d53fcc5 Compare October 26, 2024 17:27
@ntkme ntkme force-pushed the embedded-compiler branch 9 times, most recently from d7e6206 to b3794eb Compare October 28, 2024 06:35
@ntkme ntkme marked this pull request as ready for review October 28, 2024 06:49
@ntkme ntkme force-pushed the embedded-compiler branch 3 times, most recently from 9112b44 to 54fabf3 Compare October 28, 2024 07:42
@ntkme ntkme force-pushed the embedded-compiler branch 8 times, most recently from 257b4fd to ac718ee Compare October 28, 2024 21:03
@ntkme ntkme force-pushed the embedded-compiler branch 4 times, most recently from 9cc1a2f to 1586bbd Compare November 4, 2024 20:14
@nex3
Copy link
Contributor

nex3 commented Nov 4, 2024

This PR is on my radar, it's just been a very review-heavy few weeks for me and this is unfortunately on the low end of the priority spectrum.

@ntkme ntkme force-pushed the embedded-compiler branch 8 times, most recently from 6a51bdf to d11f856 Compare November 11, 2024 22:06
@ntkme ntkme force-pushed the embedded-compiler branch 5 times, most recently from 9e7f584 to 3d1c155 Compare November 15, 2024 23:02
@ntkme ntkme force-pushed the embedded-compiler branch 2 times, most recently from 99577d1 to d3c7314 Compare November 16, 2024 00:37
@ntkme
Copy link
Contributor Author

ntkme commented Nov 16, 2024

GitHub Actions revealed an interesting race condition - running postMessage() immediately followed by process.exit() in the worker may not exit immediately, and while the worker has not finished exiting, the main thread could call worker.terminate() based on the received message, which will cause the worker to have exitCode = 1 instead of whatever exitCode was set by worker.

To overcome this issue, I decided to use the first byte we added to the message buffer to explicitly send the exitCode to the main thread, so we don't need to wait for the unreliable async exit event from worker.

@ntkme
Copy link
Contributor Author

ntkme commented Nov 16, 2024

Ok, one more quirk for node worker. The way stdout/stderr stream in the worker thread works is that the worker posts message to the main thread and then the main thread writes the message asynchronously. So we cannot eagerly exit the main isolate, or otherwise the error message that the worker printed to stderr might get lost.

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.

Implement sass --embedded in pure JS mode
2 participants