Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/remove-invalid-mtf-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lynx-js/react": patch
---

Stop warning when `runWorklet` receives an invalid or missing main-thread function object. Invalid worklet contexts are still ignored, but nullish handler values no longer produce noisy `MainThreadFunction: Invalid function object` console output.
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,14 @@ describe('Worklet', () => {

it('should not throw when invalid worklet ctx', () => {
initWorklet();
consoleMock.mockClear();

globalThis.runWorklet({});
expect(consoleMock).lastCalledWith('MainThreadFunction: Invalid function object: {}');
globalThis.runWorklet(undefined);
expect(consoleMock).lastCalledWith('MainThreadFunction: Invalid function object: undefined');
globalThis.runWorklet(null);
expect(consoleMock).lastCalledWith('MainThreadFunction: Invalid function object: null');
globalThis.runWorklet(1);
expect(consoleMock).lastCalledWith('MainThreadFunction: Invalid function object: 1');

expect(consoleMock).not.toHaveBeenCalled();
});

it('should not throw when depth of argument exceeds limit', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ function registerWorklet(_type: string, id: string, worklet: (...args: unknown[]
*/
function runWorklet(ctx: Worklet, params: ClosureValueType[], options?: RunWorkletOptions): unknown {
if (!validateWorklet(ctx)) {
console.warn('MainThreadFunction: Invalid function object: ' + JSON.stringify(ctx));
return;
}

Expand Down
Loading