You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code works without errors using inversify 5.1 but fails in inversify 6
import { Container } from "inversify";
const container = new Container();
const s = Symbol('foo');
container.bind(s).toConstantValue(undefined);
console.log(container.get(s));
container.unbindAll();
produces:
/project/node_modules/inversify/lib/container/container.js:453
var constructor = Object.getPrototypeOf(instance).constructor;
^
TypeError: Cannot convert undefined or null to object
at Function.getPrototypeOf (<anonymous>)
at Container._deactivate (/project/node_modules/inversify/lib/container/container.js:453:34)
at Container._deactivateIfSingleton (/project/node_modules/inversify/lib/container/container.js:634:21)
at Container._deactivateSingletons (/project/node_modules/inversify/lib/container/container.js:639:31)
at /project/node_modules/inversify/lib/container/container.js:287:19
at /project/node_modules/inversify/lib/container/lookup.js:113:13
at Map.forEach (<anonymous>)
at Lookup.traverse (/project/node_modules/inversify/lib/container/lookup.js:112:19)
at Container.unbindAll (/project/node_modules/inversify/lib/container/container.js:286:33)
at file:///project/inversify-bug.mjs:10:11
The text was updated successfully, but these errors were encountered:
simhnna
changed the title
regression in inversify 6: no longer handles singletons with value undefined
regression: v6 no longer handles singletons with value undefinedJul 26, 2023
Actually primitive types apparently also cause issues. Using a number instead of undefined results in the following stacktrace
/project/node_modules/inversify/lib/container/container.js:467
throw new Error(ERROR_MSGS.ON_DEACTIVATION_ERROR(constructor.name, ex.message));
^
Error: onDeactivation() error in class Number: Reflect.hasMetadata is not a function
at Container._deactivate (/project/node_modules/inversify/lib/container/container.js:467:19)
at Container._deactivateIfSingleton (/project/node_modules/inversify/lib/container/container.js:634:21)
at Container._deactivateSingletons (/project/node_modules/inversify/lib/container/container.js:639:31)
at /project/node_modules/inversify/lib/container/container.js:287:19
at /project/node_modules/inversify/lib/container/lookup.js:113:13
at Map.forEach (<anonymous>)
at Lookup.traverse (/project/node_modules/inversify/lib/container/lookup.js:112:19)
at Container.unbindAll (/project/node_modules/inversify/lib/container/container.js:286:33)
at file:///project/inversify-bug.mjs:10:11
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
This code works without errors using inversify 5.1 but fails in inversify 6
produces:
The text was updated successfully, but these errors were encountered: