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.

Error using interception API with SyncBailHook

See original GitHub issue

Here is a simple configuration I had while linked up to webpack#next

webpack.config.js

const path = require('path');
const webpack = require('webpack');

module.exports = {
    entry: './src',
    output: {
        path: path.join(__dirname, 'dist'),
        filename: 'chunk.js'
    },
    plugins: [
        new webpack.ProgressPlugin(),
        function () {
            const compiler = this;

            Object.keys(compiler.hooks).forEach((hookName) => {
                compiler.hooks[hookName].intercept(interceptorFor(hookName));
            });
        }
    ]
};

const interceptorFor = (hookName) => ({
    call: (...args) => {
        console.log(`Intercepting Call: ${hookName}\n Args: ${JSON.stringify([...args])}`);
    },
    tap: (tapDetails) => {
        console.log(`Intercepting Tap: ${JSON.stringify(tapDetails)}`);
    } 
});

This is the error that threw:

console output

TypeError: Cannot read property 'fn' of undefined
    at SyncBailHook.eval [as call] (eval at compile (/mnt/c/Users/selarkin/Code/webpack/node_modules/tapable/lib/Hook.js:21:10), <anonymous>:12:28)
    at SyncBailHook.eval [as _call] (eval at createCompileDelegate (/mnt/c/Users/selarkin/Code/webpack/node_modules/tapable/lib/Hook.js:55:10), <anonymous>:5:16)
    at WebpackOptionsApply.process (/mnt/c/Users/selarkin/Code/webpack/lib/WebpackOptionsApply.js:264:30)
    at webpack (/mnt/c/Users/selarkin/Code/webpack/lib/webpack.js:35:48)
    at processOptions (/mnt/c/Users/selarkin/Code/webpack/bin/webpack.js:357:15)
    at yargs.parse (/mnt/c/Users/selarkin/Code/webpack/bin/webpack.js:418:2)
    at Object.Yargs.self.parse (/mnt/c/Users/selarkin/Code/webpack/node_modules/yargs/yargs.js:533:18)
    at Object.<anonymous> (/mnt/c/Users/selarkin/Code/webpack/bin/webpack.js:154:7)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
sokracommented, Dec 11, 2017

It should be:

    tap: (tapDetails) => {
        console.log(`Intercepting Tap: ${JSON.stringify(tapDetails)}`);
        return tapDetails;
    }
0reactions
TheLarkInncommented, Dec 12, 2017

Closing as was a difference in understanding on my part. Updated docs in merge.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Writing a Plugin - webpack
This allows to intercept absolutely all the assets which are part of the compilation. However, in our example we are fine with using...
Read more >
TS: Proxy function call interception error - Stack Overflow
For this, i create Proxy for Api class instance, and try to intercept. It's need to redirect to login page if user Unauthenticated...
Read more >
tapable-ts - NPM Package Overview - Socket - Socket.dev
Start using Socket to analyze tapable-ts and its 0 dependencies to secure your ... The intercept API closely resembles the original tapable implementation....
Read more >
@pawjs/tapable NPM | npm.io
The tapable package expose many Hook classes, which can be used to create hooks for plugins. const { SyncHook, SyncBailHook, SyncWaterfallHook, SyncLoopHook ...
Read more >
node_modules/tapable/README.md - VIsioIMB_API - PLMlab
const { SyncHook, SyncBailHook, SyncWaterfallHook, SyncLoopHook, AsyncParallelHook, ... All Hooks offer an additional interception API:.
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