amark/gun · error · Error

Cannot override existing verifyClient option in `ws` configu

Error message

Cannot override existing verifyClient option in `ws` configuration.

What it means

Thrown in the Gun 'opt' hook when the user both passes a verify option (opt.verify) and already has a verifyClient function in the WebSocket options (opt.ws.verifyClient). Since this module installs its own verifyClient for origin/auth checking, a pre-existing one would be silently replaced; the guard aborts startup unless the caller explicitly sets verify.override to acknowledge the replacement.

Source

Thrown at lib/verify.js:63

Gun.on('opt', function(context) {
    var opt = context.opt || {};
    var ws = opt.ws || {};

    if (!opt.verify) {
        this.to.next(context);
        return;
    }

    /**
     *  verify when instantiating Gun can contain the following keys:
     *      allowOrigins: Array|RegExp|String
     *      auth:         String|Function
     *      authKey:      String
     *      check:        Function
     */
    var verify = opt.verify;
    if (ws.verifyClient && !verify.override) {
        throw Error('Cannot override existing verifyClient option in `ws` configuration.');
    }

    /**
     * Attach a verifyClient to the WS configuration.
     * 
     * @param  {Object}   info      Request information
     * @param  {Function} callback  Called when verification is complete
     */
    ws.verifyClient = function(info, callback) {

        // Callback Definitions
        var errorCallback = (errorCode, message) => {
            callback(false, errorCode, message);
        };
        var successCallback = () => {
            callback(true);
        };

View on GitHub (pinned to 552227599d)

Solutions

  1. Remove the verifyClient key from the ws options and let this module configure it from opt.verify (allowOrigins, auth, authKey, check)
  2. If replacing the existing verifyClient is intentional, set verify: {override: true} in the Gun options
  3. Merge your custom checks into the verify.check function instead of a raw ws.verifyClient
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/verify.js:63 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of amark/gun@552227599d (2026-09-02). Data as JSON: /api/errors/ba06965895409a95. Report an issue: GitHub.