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

[Bug] Callbacks in the JS package are broken #740

Open
luxu-gg opened this issue Mar 24, 2025 · 1 comment · May be fixed by #742
Open

[Bug] Callbacks in the JS package are broken #740

luxu-gg opened this issue Mar 24, 2025 · 1 comment · May be fixed by #742
Labels
bug Something isn't working

Comments

@luxu-gg
Copy link
Contributor

luxu-gg commented Mar 24, 2025

In the current version, ox_lib's callbacks registered via JS package are broken.

Cause:
The eventName is being mutated before calling exports.ox_lib.setValidCallback(eventName, true) which causes all callback requests to fail.
Code:

export function onClientCallback(eventName: string, cb: (playerId: number, ...args: any[]) => any) {
eventName = `__ox_cb_${eventName}`;
exports.ox_lib.setValidCallback(eventName, true)
onNet(eventName, async (resource: string, key: string, ...args: any[]) => {

Fix:

-   eventName = `__ox_cb_${eventName}`;
+  const event = `__ox_cb_${eventName}`;
  exports.ox_lib.setValidCallback(eventName, true)

-  onNet(eventName, async (resource: string, key: string, ...args: any[]) => {
+  onNet(event, async (resource: string, key: string, ...args: any[]) => {
@luxu-gg luxu-gg added the bug Something isn't working label Mar 24, 2025
@thaibossaw
Copy link

Can confirm that I can reproduce this on my end.

Checking out the parent commit and replacing the package locally fixes the issue for me.

@thaibossaw thaibossaw linked a pull request Mar 29, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants