FLUID-5904: Component which throws exception triggering self-destruction during creation will fail during cleanup

Metadata

Source
FLUID-5904
Type
Bug
Priority
Major
Status
Closed
Resolution
Fixed
Assignee
Antranig Basman
Reporter
Antranig Basman
Created
2016-05-09T20:28:53.942-0400
Updated
2016-05-11T11:22:25.546-0400
Versions
N/A
Fixed Versions
  1. 2.0
Component
  1. IoC System

Description

A component which throws an exception before its events are constructed - for example, from an expander which is used to initialise an option - will be left in a condition which cannot properly go through the cleanup lifecycle of "doDestroy" since the line that.events.onDestroy.fire() in fluid.doDestroy (currently Fluid.js line 2597) references a nonexistent event.

This was discovered whilst testing Kettle's "static middleware" error handling, which appears like this:

fluid.defaults("kettle.middleware.static", {
    gradeNames: ["kettle.plainMiddleware"],
...
    // Remember that we write this kind of rubbish because of the crummy pre-FLUID-4982 ginger world
    middleware: "@expand:kettle.middleware.static.createMiddleware({that}.options.root, {that}.options.terms, {that}.options.middlewareOptions)"
});

kettle.middleware["static"].createMiddleware = function (root, terms, middlewareOptions) {
    if (!root) {
        fluid.fail("Static middleware must have a root path configured to serve options - got ", root);
    }
...
};

This is a class of error we will have to be particularly aggressive at tackling in the post FLUID-4982 world where component construction will have to be fully transactional and Nexus-ready.

Comments