ProjectOpenSea / stream-js

A TypeScript SDK to receive pushed updates from OpenSea over websocket.

Home Page:https://docs.opensea.io/reference/stream-api-overview

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

We see error [ERROR]: [object Object] when run OpenSeaStreamClient

lehongvo opened this issue · comments

Error Image:
image
Source code:

const scanDataNFT = async () => {
    try {
        const client = new OpenSeaStreamClient({
            token: 'd69f124bbcdf4a698d86102197d74b77',
            network: Network.TESTNET,
            connectOptions: {
                transport: WebSocket
            }
        });
        client.connect();

        const collectionSlug = "creaturesnft-37";

        client.onEvents(
            collectionSlug,
            [
                EventType.ITEM_METADATA_UPDATED,
                EventType.ITEM_CANCELLED,
                EventType.ITEM_LISTED,
                EventType.ITEM_SOLD,
                EventType.ITEM_TRANSFERRED,
                EventType.ITEM_RECEIVED_OFFER,
                EventType.ITEM_RECEIVED_BID,
                EventType.COLLECTION_OFFER,
                EventType.TRAIT_OFFER,
                EventType.ORDER_INVALIDATE,
                EventType.ORDER_REVALIDATE,
            ],
            (event) => {
                console.log("event", event)
            }
        );
    } catch (error) {
        console.log(error);
    }
}

PLease, Help me fix this issue

@ryanio ,Please help me fix this issue

You have to log the error object properly otherwise I don't know what error you are receiving!

@ryanio We already try to catch this error, but we always see error
[ERROR]: [object Object]
[ERROR]: [object Object]
[ERROR]: [object Object]
[ERROR]: [object Object]
[ERROR]: [object Object]
[ERROR]: [object Object]

do console.dir(error,{depth:null})

@ryanio we try "do console.dir(error,{depth:null})" and don't see different. Please check my code

const { OpenSeaStreamClient, Network, EventType } = require('@opensea/stream-js');
const { WebSocket } = require('ws');

const scanDataNFT = async () => {
    try {
        const client = new OpenSeaStreamClient({
            token: '5936594c14684d619ee1a1847ff0caf9',
            network: Network.TESTNET,
            connectOptions: {
                transport: WebSocket
            }
        });
        client.connect();

        const collectionSlug = "creaturesnft-37";

        client.onEvents(
            collectionSlug,
            [
                EventType.ITEM_METADATA_UPDATED,
                EventType.ITEM_CANCELLED,
                EventType.ITEM_LISTED,
                EventType.ITEM_SOLD,
                EventType.ITEM_TRANSFERRED,
                EventType.ITEM_RECEIVED_OFFER,
                EventType.ITEM_RECEIVED_BID,
                EventType.COLLECTION_OFFER,
                EventType.TRAIT_OFFER,
                EventType.ORDER_INVALIDATE,
                EventType.ORDER_REVALIDATE,
            ],
            async (event) => {
                try {
                    console.log('event', JSON.stringify(event));
                } catch (e) {
                    console.dir(e,{depth:null})
                    console.log(e);
                }
            },
        );
    } catch (error) {
        console.log(error);
        console.dir(error, { depth: null });
    }
}

scanDataNFT()

@ryanio -san. maybe provider example code

how about console.log(JSON.stringify(error));

how about console.log(JSON.stringify(error));

@ryanio We try, still error
image

Hi @ryanio, We try catch all log (01, 02, 03) and we confirm this error come from your library.
We tested the collection mainnet is working ok, but collection testnet we see this error [ERROR]: [object Object]

const scanDataNFT = async () => {
    try {
        const apiKey = 'cddad7a1687e4e02bdf9164c7e9e3706';
        const client = new OpenSeaStreamClient({
            token: apiKey,
            network: Network.TESTNET,
            connectOptions: {
                transport: WebSocket
            }
        });

        const collectionSlug = "creaturesnft-37";
        //boredapeyachtclub

        client.onEvents(
            collectionSlug,
            [
                EventType.ITEM_METADATA_UPDATED,
                EventType.ITEM_CANCELLED,
                EventType.ITEM_LISTED,
                EventType.ITEM_SOLD,
                EventType.ITEM_TRANSFERRED,
                EventType.ITEM_RECEIVED_OFFER,
                EventType.ITEM_RECEIVED_BID,
                EventType.COLLECTION_OFFER,
                EventType.TRAIT_OFFER,
                EventType.ORDER_INVALIDATE,
                EventType.ORDER_REVALIDATE,
            ],
            async (event) => {
                try {
                    console.log("01");
                    console.log('event', JSON.stringify(event));
                } catch (e) {
                    console.log("02");
                    console.dir(e,{depth:null})
                }
            },
        );
    } catch (error) {
        console.log("03");
        console.log(JSON.stringify(error));
    }
}

@ryanio Please help me check this issue.

@ryanio please help me fix this issue

looks like #325 will help fix, i will try to get that in and release it today