From b978171e0cb426a4acf6dfe614e6a24b9e14a13e Mon Sep 17 00:00:00 2001 From: James Allen Date: Fri, 5 Feb 2016 15:39:26 +0000 Subject: [PATCH] Fix "cannot set headers after sent" in setting doc end point If somehow a project ends up with the same doc/file in two locations in the file tree, then projectLocator.findElement will return the callback for both entries. This then tries to end the request multiple times. Of course this should never be a state the project is in, but if it is we should catch it. --- .../web/app/coffee/Features/Project/ProjectLocator.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/web/app/coffee/Features/Project/ProjectLocator.coffee b/services/web/app/coffee/Features/Project/ProjectLocator.coffee index fbf5b1bb5f..fe60e0ba3e 100644 --- a/services/web/app/coffee/Features/Project/ProjectLocator.coffee +++ b/services/web/app/coffee/Features/Project/ProjectLocator.coffee @@ -5,7 +5,11 @@ logger = require('logger-sharelatex') async = require('async') module.exports = - findElement: (options, callback = (err, element, path, parentFolder)->)-> + findElement: (options, _callback = (err, element, path, parentFolder)->)-> + callback = (args...) -> + _callback(args...) + _callback = () -> + {project, project_id, element_id, type} = options elementType = sanitizeTypeOfElement type