kkemple / kkemple/primus-webpack-plugin

Failed to send event

Open
#2 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
6
Forks
9
PR merge metrics
No merged PRs in 30d

Description

I setup `primus-webpack-plugin` in webpack configuration file as below.

```
new PrimusWebpackPlugin({
filename: 'primus-client.js',
minify: true,
primusOptions: {
transformer: 'websockets',
timeout: false,
}
}),
```

In the js code, I import `Primus` and use it to send event to server as below:

```
import feathers from 'feathers-client';
import Primus from '../../../dist/primus-client';
const primus = new Primus(url);
const app =feathers().configure(feathers.hooks()).configure(feathers.primus(primus));
app.service('my service').create('...')
```

after doing this, I got below exception from the last line of above code:

```
connection failed TypeError: Cannot read property 'apply' of undefined
at client.js:104
at Object.send (client.js:82)
at Object.create (client.js:126)
at hooks.js:101
at hooks.js:85
```

It works fine if I serve the `primus client` from a static server. I only got this error when I use this webpack plugin.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the webpack configuration and compare the generated dist/primus-client.js with the client served from a static server. Trace client.js around lines 82, 104, and 126, then follow the feathers hooks.js calls that lead to the error. Done means reproducing the failure and identifying a plugin-generated client that can send the service event successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, webpack
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.