question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using the npm version of botframework-webchat causes an issue with browserify-sign package during bundling.

See original GitHub issue

Hi, I have been using the CDN version of botframework-webchat in my app without any issues, but recently decided to switch to the npm version. However, ever since I installed the npm version, I get a strange error in my console Uncaught TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object. as shown below:- Screenshot 2020-01-09 at 11 37 56 AM

browserify-sign is not a direct dependency of my application and until I was importing botframework-webchat from CDN, this issue did not come up. It was only after I switched to importing the npm version does this happen.

I am using botframework-webchat version 4.7.1, along with webpack version 4.39.3.

Here is my webpack config for your reference:

var webpack = require("webpack");
const CompressionPlugin = require("compression-webpack-plugin");
const HtmlWebPackPlugin = require("html-webpack-plugin");

module.exports = {
    module: {
    rules: [
      {
        test: /\.html$/,
        loader: "html-loader"
      },
      {
        test: /\.(scss|css)$/,
        loaders: ["style-loader", "css-loader", "sass-loader"]
      },
      {
        test: /\.(png|jpg|gif)(\?v=\d+\.\d+\.\d+)?$/,
        loader: "url-loader?limit=
      },
     {
        test: /\.(eot|com|ttf|woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
        loader: "url-loader?limit=10000&mimetype=application/octet-stream"
      },
      {
        test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
        loader: "url-loader?limit=10000&mimetype=image/svg+xml"
      },
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader",
            options: {
                presets: ["@babel/preset-react", "@babel/preset-env"]
              }
          }
       },
      {
        type: "javascript/auto",
        test: /\.json$/,
        use: [
           {
              loader: "file-loader",
              options: {
                 name: "[name].[ext]"
                   }
            }
          ]
       }
    ]
  },
  optimization: {
  minimize: true
  },
  devServer: {
     disableHostCheck: true,
     proxy: {
       "/api": "http://localhost:8000"
      },
     stats: {
      children: false,
      modules: false
     }
  },
   plugins: [
     new webpack.DefinePlugin({
       "process.env": {
          NODE_ENV: JSON.stringify("production")
        }
    }),
    new webpack.optimize.AggressiveMergingPlugin(),
    new CompressionPlugin({
      filename: "[path].gz[query]",
      algorithm: "gzip",
      test: /\.js$|\.css$|\.html$|\.eot?.+$|\.ttf?.+$|\.woff?.+$|\.svg?.+$/,
      threshold: 10240,
      minRatio: 0.8
    }),
    new webpack.ProvidePlugin({
        Promise: "es6-promise-promise"
    }),
    new HtmlWebPackPlugin({
      template: "./src/index.html",
      filename: "./index.html",
      inject: 'body'
    })
   ]
};

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
corinagumcommented, Jan 9, 2020

Hi @manishams10, thanks for the information. We’ll get a repro going on our side and get back to you.

0reactions
compulimcommented, Feb 26, 2020

Nailed it!

In your webpack.config.js, your .json module resolver is loading files thru file-loader. It should be loaded from json-loader.

Since JSON files are not loaded properly, this line in browserify-sign will not load the algorithms.json properly.

You can look at the repro with the fix at https://github.com/compulim/botframework-webchat-repro-2804.

The fix your app, you can apply the diff below.

  var webpack = require("webpack");
  const CompressionPlugin = require("compression-webpack-plugin");
  const HtmlWebPackPlugin = require("html-webpack-plugin");
  
  module.exports = {
      module: {
      rules: [
        {
          test: /\.html$/,
          loader: "html-loader"
        },
        {
          test: /\.(scss|css)$/,
          loaders: ["style-loader", "css-loader", "sass-loader"]
        },
        {
          test: /\.(png|jpg|gif)(\?v=\d+\.\d+\.\d+)?$/,
          loader: "url-loader?limit=
        },
       {
          test: /\.(eot|com|ttf|woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
          loader: "url-loader?limit=10000&mimetype=application/octet-stream"
        },
        {
          test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
          loader: "url-loader?limit=10000&mimetype=image/svg+xml"
        },
        {
          test: /\.(js|jsx)$/,
          exclude: /node_modules/,
          use: {
            loader: "babel-loader",
              options: {
                  presets: ["@babel/preset-react", "@babel/preset-env"]
                }
            }
         },
        {
          type: "javascript/auto",
          test: /\.json$/,
          use: [
             {
-               loader: "file-loader",
+               loader: "json-loader",
                options: {
                   name: "[name].[ext]"
                     }
              }
            ]
         }
      ]
    },
    optimization: {
    minimize: true
    },
    devServer: {
       disableHostCheck: true,
       proxy: {
         "/api": "http://localhost:8000"
        },
       stats: {
        children: false,
        modules: false
       }
    },
     plugins: [
       new webpack.DefinePlugin({
         "process.env": {
            NODE_ENV: JSON.stringify("production")
          }
      }),
      new webpack.optimize.AggressiveMergingPlugin(),
      new CompressionPlugin({
        filename: "[path].gz[query]",
        algorithm: "gzip",
        test: /\.js$|\.css$|\.html$|\.eot?.+$|\.ttf?.+$|\.woff?.+$|\.svg?.+$/,
        threshold: 10240,
        minRatio: 0.8
      }),
      new webpack.ProvidePlugin({
          Promise: "es6-promise-promise"
      }),
      new HtmlWebPackPlugin({
        template: "./src/index.html",
        filename: "./index.html",
        inject: 'body'
      })
     ]
  };
Read more comments on GitHub >

github_iconTop Results From Across the Web

botframework-webchat - npm
A highly-customizable web-based chat client for Azure Bot Services.. Latest version: 4.15.3, last published: a month ago. Start using ...
Read more >
botframework-webchat - npm
A highly-customizable web-based chat client for Azure Bot Services.. Latest version: 4.15.6, last published: 23 days ago. Start using ...
Read more >
botframework-webchat - npm
A highly-customizable web-based chat client for Azure Bot Services.. Latest version: 4.15.3, last published: 17 days ago. Start using ...
Read more >
Common errors | npm Docs
If you are having trouble with npm install , use the -verbose option to see ... and npm" and "Resolving EACCES permissions errors...
Read more >
botframework-webchat - npm
A highly-customizable web-based chat client for Azure Bot Services.. Latest version: 4.15.3, last published: 14 days ago. Start using ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found