Skip to content

error: Error syncing incoming transactions offset is not uint [RangeError: offset is not uint] #395

Closed

Description

@dashameter

I'm getting

error: Error syncing incoming transactions offset is not uint [RangeError: offset is not uint]
index.js?b639:1097 Uncaught (in promise) RangeError: offset is not uint
    at checkOffset (index.js?b639:1097:1)
    at Uint8Array.readUInt32BE (index.js?b639:1157:1)
    at eval (sortTransactions.js?670d:35:1)
    at Array.forEach (<anonymous>)
    at eval (sortTransactions.js?670d:34:1)
    at Array.sort (<anonymous>)
    at eval (sortTransactions.js?670d:31:1)
    at Array.reduce (<anonymous>)
    at sortTransactions (sortTransactions.js?670d:30:1)
    at ChainStore.importAddress (importAddress.js?2682:27:1)
/*
 * Need to make sure that buffer isn't trying to write out of bounds.
 */
function checkOffset (offset, ext, length) {
  if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
}
return Object.keys(transactionsByHeight)
    .sort((a, b) => parseInt(a, 10) - parseInt(b, 10))
    .reduce((acc, height) => {
      transactionsByHeight[height].sort((a, b) => {
        // const prevTxHashBuffer = Buffer.alloc(32);
        const prevTxHashes = new Set();
        b.inputs.forEach((input) => {
+          if (input.prevTxId.readUInt32BE() !== 0) {
            prevTxHashes.add(input.prevTxId.toString('hex'));
          }
        });

        if (prevTxHashes.has(a.hash)) {
          return -1;
        }
        return 0;
      });
      return acc.concat(transactionsByHeight[height]);
    }, []);

using dashmate 22.7

This seems to be related to webpack5

Activity

  1. added
    bug
    on May 17, 2022
  2. mayoreee commented on May 18, 2022

    @mayoreee

    Workaround 1

    For using Dash SDK with Webpack 5

    1. Change the content of vue.config.js to:
    module.exports = {
      configureWebpack: {
        resolve: {
          alias: {
            zlib: require.resolve('browserify-zlib'),
            http: require.resolve('stream-http'),
            https: require.resolve('https-browserify'),
            os: require.resolve('os-browserify/browser'),
            path: require.resolve('path-browserify'),
            fs: require.resolve('fs'),
            util: require.resolve('util'),
            stream: require.resolve('stream-browserify'),
            assert: require.resolve('assert'),
            crypto: require.resolve('crypto-browserify'),
            url: require.resolve('url'),
          },
        },
      },
    };
    
    1. Run these commands:
    npm i browserify-zlib
    npm i stream-http
    npm i https-browserify
    npm i os-browserify
    npm i path-browserify
    npm i fs
    npm i util
    npm i stream-browserify
    npm i assert
    npm i crypto-browserify
    npm i url
    
    1. npm run serve
  3. mayoreee commented on May 18, 2022

    @mayoreee

    Workaround 2

    For using Dash SDK with Vite

    1. Change the content of vue.config.js to:
    import { fileURLToPath, URL } from 'url'
    
    import { defineConfig } from 'vite'
    import vue from '@vitejs/plugin-vue'
    
    // https://vitejs.dev/config/
    export default defineConfig({
      plugins: [vue()],
      resolve: {
        alias: {
          zlib: require.resolve('browserify-zlib'),
          http: require.resolve('stream-http'),
          https: require.resolve('https-browserify'),
          os: require.resolve('os-browserify/browser'),
          path: require.resolve('path-browserify'),
          fs: require.resolve('fs'),
          util: require.resolve('util'),
          stream: require.resolve('stream-browserify'),
          assert: require.resolve('assert'),
          crypto: require.resolve('crypto-browserify'),
          url: require.resolve('url'),
        },
      },
    })
    
    
    1. Run these commands:
    npm i browserify-zlib
    npm i stream-http
    npm i https-browserify
    npm i os-browserify
    npm i path-browserify
    npm i fs
    npm i util
    npm i stream-browserify
    npm i assert
    npm i crypto-browserify
    npm i url
    
    1. npm run dev
  4. markin-io commented on May 20, 2022

    @markin-io
    Contributor
  5. dashameter commented on May 22, 2022

    @dashameter
    ContributorAuthor

    I'm getting the error:

    error: Error syncing incoming transactions offset is not uint [RangeError: offset is not uint]
    index.js:1097 Uncaught (in promise) RangeError: offset is not uint
        at X (index.js:1097:47)
        at Uint8Array.E.readUInt32BE (index.js:1157:18)
        at sortTransactions.js:35:30
        at Array.forEach (<anonymous>)
        at sortTransactions.js:34:18
        at Array.sort (<anonymous>)
        at sortTransactions.js:31:36
        at Array.reduce (<anonymous>)
        at e (sortTransactions.js:30:6)
        at o.n [as importAddress] (importAddress.js:27:32)
    X @ index.js:1097
    E.readUInt32BE @ index.js:1157
    (anonymous) @ sortTransactions.js:35
    (anonymous) @ sortTransactions.js:34
    (anonymous) @ sortTransactions.js:31
    e @ sortTransactions.js:30
    n @ importAddress.js:27
    (anonymous) @ addPathsToStore.js:16
    e @ addPathsToStore.js:13
    (anonymous) @ importTransactions.js:37
    A.exports @ importTransactions.js:20
    s @ processChunks.js:37
    (anonymous) @ onStreamData.js:7
    processJob @ Queue.js:41
    processNext @ Queue.js:35
    t @ Queue.js:52
    I @ events.js:243
    s.emit @ events.js:153
    enqueueJob @ Queue.js:23
    n @ onStreamData.js:7
    (anonymous) @ syncUpToTheGapLimit.js:55
    (anonymous) @ index.js:49
    qA @ index.js:34
    zA @ index.js:33
    Mt @ index.js:41
    pt.O @ index.js:40
    pt.K @ index.js:40
    VM383:1          POST http://54.187.50.120:3000/org.dash.platform.dapi.v0.Core/subscribeToTransactionsWithProofs 504 
    VM383:1          POST http://34.215.144.176:3000/org.dash.platform.dapi.v0.Core/subscribeToTransactionsWithProofs 504 
    VM383:1          POST http://34.211.49.3:3000/org.dash.platform.dapi.v0.Core/subscribeToTransactionsWithProofs 
    VM383:1          POST http://35.166.29.155:3000/org.dash.platform.dapi.v0.Core/subscribeToTransactionsWithProofs 504 (Gateway Time-out)
    

    on testnet during identity creation using webpack 4.

    Sometimes I get it with dashmate and webpack 4 but if I refresh the walelt often enough the error goes away and I can use the sdk as expect 🤔

  6. dashameter commented on Jun 16, 2022

    @dashameter
    ContributorAuthor

    retest passed [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions