Skip to content

RemoteRunnable within React Error #6520

Answered by dosubot bot
nacartwright asked this question in Q&A
Aug 13, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

To resolve the "Failed to execute 'fetch' on 'Window': Illegal invocation" error when trying to execute RemoteRunnable within your React application, ensure that the fetchImplementation is correctly bound to the RemoteRunnable class. The error typically occurs when the fetch function loses its context.

In your code, you need to bind the fetch function to the window object. Here is an example of how you can instantiate RemoteRunnable with a properly bound fetch function:

import { RemoteRunnable } from "langchain/runnables/remote";
import { useEffect, useRef } from "react";

const MyComponent = () => {
    const remoteChain = useRef(null);

    useEffect(() => {
        // Ensure fetch is …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@nacartwright
Comment options

@dosubot
Comment options

Answer selected by nacartwright
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant