Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect autoloading dead locks #108

Closed
nfroidure opened this issue Dec 1, 2019 · 0 comments · Fixed by #126
Closed

Detect autoloading dead locks #108

nfroidure opened this issue Dec 1, 2019 · 0 comments · Fixed by #126
Milestone

Comments

@nfroidure
Copy link
Owner

Dead locks can happen when autoloading and reusing a service descriptor, the following test fails:

knifecycle/src/index.mocha.js

Lines 983 to 1026 in 8079b99

it.skip('should work when autoload depends on deeper optional and unexisting autoloaded dependencies', async () => {
$.register(
initializer(
{
type: 'service',
name: 'log',
inject: ['?LOG_ROUTING', '?LOGGER', '?debug'],
},
async () => {
return function log() {};
},
),
);
$.register(constant('LOGGER', 'LOGGER_CONSTANT'));
$.register(constant('debug', 'debug_value'));
$.register(
initializer(
{
type: 'service',
name: '$autoload',
inject: ['?ENV', '?log'],
options: {
singleton: true,
},
},
async () => async serviceName => ({
path: `/path/of/${serviceName}`,
initializer: initializer(
{
type: 'service',
name: serviceName,
inject: [],
},
async () => `THE_${serviceName.toUpperCase()}:` + serviceName,
),
}),
),
);
const dependencies = await $.run(['test', 'log']);
assert.deepEqual(Object.keys(dependencies), ['test', 'log']);
});
});

Instead of passing an autoloading boolean, a function that checks for autoloading in all dependencies would allow to detect such situation and completely avoid dead locks.

@nfroidure nfroidure added this to the 16.0.0 milestone Aug 15, 2023
nfroidure added a commit that referenced this issue Aug 15, 2023
fix #108
fix #120 removed and replace by a simple getter (`_getInitializer`)
fix #34 refusing to override instanciated initializers
nfroidure added a commit that referenced this issue Aug 15, 2023
fix #108
fix #120 removed and replace by a simple getter (`_getInitializer`)
fix #34 refusing to override instanciated initializers
nfroidure added a commit that referenced this issue Aug 16, 2023
fix #108
fix #120 removed and replace by a simple getter (`_getInitializer`)
fix #34 refusing to override instanciated initializers
nfroidure added a commit that referenced this issue Aug 16, 2023
fix #108
fix #120 removed and replace by a simple getter (`_getInitializer`)
fix #34 refusing to override instanciated initializers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant