Suppress error log on unbind

In one of my extensions, I am doing this

export default new ContainerModule((bind, unbind, isBound, rebind)  => {
    unbind(DefaultJsonSchemaContribution);
    ....
    bind(FrontendApplicationContribution).toService(CustomHideWidgetsContribution);
}

Error:

root ERROR Error: No matching bindings found for serviceIdentifier: DefaultJsonSchemaContribution
    at _validateActiveBindingCount (http://localhost:3000/bundle.js:86003:23)
    at _getActiveBindings (http://localhost:3000/bundle.js:85989:5)
    at _createSubRequests (http://localhost:3000/bundle.js:86026:26)
    at Object.plan (http://localhost:3000/bundle.js:86077:9)
    at http://localhost:3000/bundle.js:85599:37
    at Container.../node_modules/inversify/lib/container/container.js.Container._get (http://localhost:3000/bundle.js:85592:44)
    at Container.../node_modules/inversify/lib/container/container.js.Container.get (http://localhost:3000/bundle.js:85512:21)
    at Binding.dynamicValue (http://localhost:3000/bundle.js:86807:75)
    at http://localhost:3000/bundle.js:86546:118
    at invokeFactory (http://localhost:3000/bundle.js:86493:16)

@vinayb21 it is expected, DefaultJsonSchemaContribution needs to be binded in some form since it is used/referenced. It’s not possible to simply unbind.

@vince-fugnitto
I created a custom Json schema contribution and rebinded JsonSchema:

import {JsonSchemaRegisterContext, DefaultJsonSchemaContribution, JsonSchemaContribution} from  '@theia/core/lib/browser/json-schema-store'

const catalog: any = {
    "$schema": "https://json.schemastore.org/schema-catalog",
    "version": 1.0,
    "schemas": []
}

@injectable()
export class CustomJsonSchemaContribution implements JsonSchemaContribution {
    async registerSchemas(context: JsonSchemaRegisterContext): Promise<void> {
        const schemas: DefaultJsonSchemaContribution.SchemaData[] = catalog.schemas!;
        for (const s of schemas) {
            console.log(s);
            if (s.fileMatch) {
                context.registerSchema({
                    fileMatch: s.fileMatch,
                    url: s.url
                });
            }
        }
    }
}

Added the following lines instead of unbind:

    bind(CustomJsonSchemaContribution).toSelf().inSingletonScope();
    rebind(JsonSchemaContribution).toService(DefaultJsonSchemaContribution);

Still getting the same error
Do you know how to solve this? :confused:

Fixed it by the following snippet:

unbind(DefaultJsonSchemaContribution);
bind(DefaultJsonSchemaContribution).to(CustomJsonSchemaContribution).inSingletonScope();
rebind(JsonSchemaContribution).toService(DefaultJsonSchemaContribution);