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

utils: Override async functions with async functions #2163

Closed

Conversation

vanvugt
Copy link
Collaborator

@vanvugt vanvugt commented Mar 20, 2024

Otherwise gnome-shell (LayoutManager._loadBackground) can't find the override when it was expecting an async function.

Closes: #2110

Otherwise gnome-shell (LayoutManager._loadBackground) can't find the
override when it was expecting an async function.

Closes: micheleg#2110
@vanvugt vanvugt force-pushed the silence-prepareStartupAnimation2 branch from 56ba256 to 6244ce4 Compare March 20, 2024 09:28
object[name] = function (...args) {
return injectedFunction.call(this, original, ...args);
};
if (original.constructor.name === 'AsyncFunction') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, funny thing... I had this changed months ago and I forgot to commit...

However, define something like const AsyncFunctionType = (async () => {}).constructor; and then check for original instanceof AsyncFunctionType.

Also I feel we should check if the two things match, so if both the original ones are async or not and depending on that behave differently.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I saw that suggestion when googling but it felt like a hack so I intentionally didn't do it that way. It's uglier, more code, and not obviously correct to me.

Good point about checking two things match though...

Since it turns out the bug #2110 actually isn't important, and it's fixed by #2166, and you have another fix in mind, I suggest just merging your own fix or wait for #2166.

Comment on lines +327 to +329
object[name] = async function (...args) {
return injectedFunction.call(this, original, ...args);
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

So, if you're declaring this async and injectedFunction that would be meant to await, so I think you can just drop the async and return the promise as it is no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I expect #2110 will be solved either by #2166 or by your own commit you said you had, or both. So we don't need to continue here.

@vanvugt vanvugt closed this Mar 28, 2024
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.

JS ERROR: TypeError: this._prepareStartupAnimation() is undefined
2 participants