{"action":"closed","issue":{"url":"https://api.github.com/repos/0xProject/0x-monorepo/issues/1172","repository_url":"https://api.github.com/repos/0xProject/0x-monorepo","labels_url":"https://api.github.com/repos/0xProject/0x-monorepo/issues/1172/labels{/name}","comments_url":"https://api.github.com/repos/0xProject/0x-monorepo/issues/1172/comments","events_url":"https://api.github.com/repos/0xProject/0x-monorepo/issues/1172/events","html_url":"https://github.com/0xProject/0x-monorepo/issues/1172","id":372240025,"node_id":"MDU6SXNzdWUzNzIyNDAwMjU=","number":1172,"title":"OrderWatch Bug: UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object or Error: Failed to fetch parent block.","user":{"login":"coinpennant","id":33878806,"node_id":"MDQ6VXNlcjMzODc4ODA2","avatar_url":"https://avatars2.githubusercontent.com/u/33878806?v=4","gravatar_id":"","url":"https://api.github.com/users/coinpennant","html_url":"https://github.com/coinpennant","followers_url":"https://api.github.com/users/coinpennant/followers","following_url":"https://api.github.com/users/coinpennant/following{/other_user}","gists_url":"https://api.github.com/users/coinpennant/gists{/gist_id}","starred_url":"https://api.github.com/users/coinpennant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coinpennant/subscriptions","organizations_url":"https://api.github.com/users/coinpennant/orgs","repos_url":"https://api.github.com/users/coinpennant/repos","events_url":"https://api.github.com/users/coinpennant/events{/privacy}","received_events_url":"https://api.github.com/users/coinpennant/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-10-20T18:34:36Z","updated_at":"2018-11-12T10:21:21Z","closed_at":"2018-11-12T10:21:21Z","author_association":"NONE","body":"<!--- Thank you for taking the time to file an Issue -->\r\n\r\n<!--- Before submitting please check to see if this issue was already reported -->\r\n\r\n<!--- Provide a general summary of the issue in the Title above -->\r\n\r\n## Expected Behavior\r\n\r\nShould run in infura mainnet.\r\n\r\n## Current Behavior\r\n\r\nC:\\Users\\mitja\\Downloads\\order-watch2>node ./dist/main.js\r\n```\r\nstart\r\nend 2\r\n6551584\r\n1\r\nend\r\n\r\n{ code: -32000, message: 'unknown block' }\r\n{ code: -32000, message: 'unknown block' }\r\n{ code: -32000, message: 'unknown block' }\r\nError: Failed to fetch parent block.\r\n    at Object.<anonymous> (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\ethereumjs-blockstream\\output\\source\\block-reconciler.js:106:27)\r\n    at step (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\ethereumjs-blockstream\\output\\source\\block-reconciler.js:32:23)\r\n    at Object.next (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\ethereumjs-blockstream\\output\\source\\block-reconciler.js:13:53)\r\n    at fulfilled (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\ethereumjs-blockstream\\output\\source\\block-reconciler.js:4:58)\r\n    at <anonymous>\r\n    at process._tickCallback (internal/process/next_tick.js:188:7)\r\n\r\n\r\n(node:16972) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object\r\n    at Function.from (native)\r\n    at DependentOrderHashesTracker.getDependentOrderHashesByMaker (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\dependent_order_hashes_tracker.js:47:42)\r\n    at OrderWatcher.<anonymous> (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\order_watcher.js:401:73)\r\n    at step (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\order_watcher.js:43:23)\r\n    at Object.next (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\order_watcher.js:24:53)\r\n    at C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\order_watcher.js:18:71\r\n    at new Promise (<anonymous>)\r\n    at __awaiter (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\order_watcher.js:14:12)\r\n    at OrderWatcher._onEventWatcherCallbackAsync (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\order_watcher.js:275:16)\r\n    at EventWatcher.<anonymous> (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:213:21)\r\n    at step (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:43:23)\r\n    at Object.next (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:24:53)\r\n    at C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:18:71\r\n    at new Promise (<anonymous>)\r\n    at __awaiter (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:14:12)\r\n    at EventWatcher._emitDifferencesAsync (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:208:16)\r\n    at EventWatcher.<anonymous> (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:176:51)\r\n    at step (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:43:23)\r\n    at Object.next (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:24:53)\r\n    at C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:18:71\r\n    at new Promise (<anonymous>)\r\n    at __awaiter (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:14:12)\r\n(node:16972) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)\r\n(node:16972) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.\r\n{ code: -32000, message: 'unknown block' }\r\n{ code: -32000, message: 'unknown block' }\r\n{ code: -32000, message: 'unknown block' }\r\n{ code: -32000, message: 'unknown block' }\r\n(node:16972) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object\r\n    at Function.from (native)\r\n    at DependentOrderHashesTracker.getDependentOrderHashesByMaker (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\dependent_order_hashes_tracker.js:47:42)\r\n    at OrderWatcher.<anonymous> (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\order_watcher.js:401:73)\r\n    at step (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\order_watcher.js:43:23)\r\n    at Object.next (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\order_watcher.js:24:53)\r\n    at C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\order_watcher.js:18:71\r\n    at new Promise (<anonymous>)\r\n    at __awaiter (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\order_watcher.js:14:12)\r\n    at OrderWatcher._onEventWatcherCallbackAsync (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\order_watcher.js:275:16)\r\n    at EventWatcher.<anonymous> (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:213:21)\r\n    at step (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:43:23)\r\n    at Object.next (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:24:53)\r\n    at C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:18:71\r\n    at new Promise (<anonymous>)\r\n    at __awaiter (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:14:12)\r\n    at EventWatcher._emitDifferencesAsync (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:208:16)\r\n    at EventWatcher.<anonymous> (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:176:51)\r\n    at step (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:43:23)\r\n    at Object.next (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:24:53)\r\n    at C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:18:71\r\n    at new Promise (<anonymous>)\r\n    at __awaiter (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\@0xproject\\order-watcher\\lib\\src\\order_watcher\\event_watcher.js:14:12)\r\n(node:16972) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)\r\n{ code: -32000, message: 'unknown block' }\r\nError: Failed to fetch parent block.\r\n    at Object.<anonymous> (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\ethereumjs-blockstream\\output\\source\\block-reconciler.js:106:27)\r\n    at step (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\ethereumjs-blockstream\\output\\source\\block-reconciler.js:32:23)\r\n    at Object.next (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\ethereumjs-blockstream\\output\\source\\block-reconciler.js:13:53)\r\n    at fulfilled (C:\\Users\\mitja\\Downloads\\order-watch2\\node_modules\\ethereumjs-blockstream\\output\\source\\block-reconciler.js:4:58)\r\n    at <anonymous>\r\n    at process._tickCallback (internal/process/next_tick.js:188:7)\r\n(node:16972) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object\r\n    at Function.from (native)\r\n```\r\n\r\n## Possible Solution\r\n\r\n<!--- Not obligatory, but suggest a fix/reason for the bug, -->\r\n\r\n<!--- or ideas how to implement the addition or change -->\r\n\r\n## Steps to Reproduce (for bugs)\r\n\r\n<!--- Provide a link to a live example, or an unambiguous set of steps to -->\r\n\r\n<!--- reproduce this bug. Include code to reproduce, if relevant -->\r\n\r\n```\r\n1. npm install\r\n2. tsc\r\n3. node ./dist/main.js\r\n```\r\n\r\nmain.ts\r\n\r\n\r\n```\r\nimport { OrderWatcher, OnOrderStateChangeCallback, OrderWatcherConfig } from '@0xproject/order-watcher';\r\nimport { SignerSubprovider, RPCSubprovider, Web3ProviderEngine } from '@0xproject/subproviders';\r\nimport { Web3Wrapper } from '@0xproject/web3-wrapper';\r\n\r\nlet url = 'https://mainnet.infura.io/0a8359dc4ae54b7c9406bb0b09422afe';\r\n//let url = 'http://localhost:8545';\r\nlet provider = new RPCSubprovider(url);\r\nconst providerEngine = new Web3ProviderEngine();\r\nproviderEngine.addProvider(provider);\r\nproviderEngine.start();\r\n\r\nlet orderWatcher = null;\r\n\r\nfunction delay(milliseconds: number, count: number): Promise<number> {\r\n    return new Promise<number>(resolve => {\r\n            setTimeout(() => {\r\n                resolve(count);\r\n            }, milliseconds);\r\n        });\r\n}\r\n\r\nasync function app() {\r\n    console.log('start');     \r\n\r\n        // Get all of the accounts through the Web3Wrapper\r\n        const web3Wrapper = new Web3Wrapper(providerEngine);\r\n        const blockNumber = await web3Wrapper.getBlockNumberAsync();\r\n        const networkId = await web3Wrapper.getNetworkIdAsync();\r\n        \r\n        console.log(blockNumber);\r\n        console.log(networkId);\r\n\r\n        //let networkId = 1;\r\n        //let partialConfig = new Partial<OrderWatcherConfig>();\r\n\r\n        orderWatcher = new OrderWatcher(\r\n        web3Wrapper.getProvider(), \r\n        networkId\r\n        );\r\n\r\n        //  orderWatcher.subscribe(\r\n        //     ( error: Error|null, orderState?: OrderState ) : void => {\r\n        //         console.log('callback');\r\n        //         console.log(error);\r\n        //         console.log(orderState);\r\n\r\n        //     }\r\n        //  );\r\n\r\n        orderWatcher.subscribe(\r\n            ( callback: OnOrderStateChangeCallback ) : void => {\r\n                console.log('callback');\r\n                //console.log(callback);\r\n            }\r\n        );    \r\n\r\n        // for (let i = 0; i < 20; i++) {\r\n        //     // await is converting Promise<number> into number\r\n        //     const count:number = await delay(1000, i);\r\n        //     console.log(count);\r\n        // }\r\n        \r\n        console.log('end');     \r\n}\r\n\r\napp()\r\n\r\nconst waitUntil = require('async-wait-until');\r\n \r\nconst timeOfStart = Date.now();\r\n\r\nwaitUntil(() => {\r\n    const timePassed = Date.now() - timeOfStart;\r\n   \r\n    return false;        \r\n}, 5 * 60 * 10000)\r\n  .then((result) => {\r\n    // Here are the operations to be done after predicate\r\n    console.log('Async operation succeeded, predicate result = ', result);\r\n  })\r\n  .catch((error) => {\r\n    // Here are the operations to be done if predicate didn't succeed in the timeout\r\n    console.log('Async operation failed: ', error);\r\n  });\r\n\r\nconsole.log('end 2');\r\n\r\n```\r\n\r\n\r\n## Context\r\n\r\n<!--- How has this issue affected you? What are you trying to accomplish? -->\r\n\r\n<!--- Providing context helps us come up with a solution that is most useful in the real world -->\r\n\r\n## Your Environment\r\n\r\n<!--- Include as many relevant details about the environment you experienced the bug in -->\r\n\r\n|             Package | Version |\r\n| ------------------: | :------ |\r\n|             `0x.js` | 2  |\r\n\r\n| Network |\r\n| ------- |\r\n| mainnet |\r\n\r\n<!-- For example:\r\n| mainnet |\r\n| kovan |\r\n| testrpc |\r\n-->\r\n"}}
{"actor":{"display_login":"fabioberger"}}