Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(cdk): mark scheduler tasks as pending tasks #1870

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

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

Conversation

hoebbelsB
Copy link
Member

Description

fixes #1867

Not the most beautiful of all solutions, but we are lacking DI context in the scheduler.

@Platonn please have a look at the solution. I've tested it on the repository you've shared with us in your issue. For me it solved the issue

@github-actions github-actions bot added the 🛠️ CDK CDK related label Apr 27, 2025
Copy link

nx-cloud bot commented Apr 27, 2025

View your CI Pipeline Execution ↗ for commit 8e93170.

Command Status Duration Result
nx affected -t lint build test component-test e... ✅ Succeeded 5m 17s View ↗
nx build docs ✅ Succeeded 24s View ↗
nx-cloud record -- npx nx format:check ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2025-04-27 12:15:26 UTC

@github-actions github-actions bot added </> Template @rx-angular/template related 🔬 Experimental Experimental: Feature, docs, demos labels Apr 27, 2025
@hoebbelsB hoebbelsB requested a review from eneajaho April 27, 2025 14:15
Comment on lines +20 to +27
let pendingTasks: PendingTasks | undefined;

export function setPendingTasks(p: PendingTasks) {
if (!pendingTasks) {
pendingTasks = p;
}
}

Copy link

@Platonn Platonn Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks @hoebbelsB for taking care of this issue. 🙌

Do we really have to store an application-specific instance of PendingTasks class in a global context?
I'm afraid it's prone to bugs in SSR where multiple apps rendered in parallel can overwrite this single global context property, interfering with other renderings (which ideally should be independent).

More details:

  • I can see in Angular Source code, that PendingTasks is provided in the root injector, so it's scoped to a single instance of an application.
  • In SSR there can exist multiple instances of Angular applications in parallel (each being rendered for a different parallel incoming request) - all executed in the same global NodeJS context.
  • Therefore, I'm afraid in SSR parallel renderings may interfere with each other, overwriting the NodeJS global shared property let pendingTasks, which can potentially cause bugs.

Again, thank you for taking a look into this issue :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for pointing that out. It might require a bigger refactoring from our end in that case. Let me think about it

Copy link

@Platonn Platonn Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I can see in the source code of RxAngular that we're now drilling down the NgZone argument deep down through the chain of functions (from RxLet, RxFor, ... directives down to scheduleOnQueue()).

I believe the usecase for the bugfix is valid.
But I can understand your concern: "is the refactoring worth it? (e.g. drilling down an instance of PendingTasks"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛠️ CDK CDK related 🔬 Experimental Experimental: Feature, docs, demos </> Template @rx-angular/template related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RxFor destroys/recreates DOM on long initial rendering, despite Angular non-destructive hydration was enabled
3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.