injectinto your source or index.html files,
globalimport or separate script load in the case of
mainfile must be specified and the RevDeBug code is inserted directly into this file and this file must be the entry point of execution. This may get tricky with
importdeclarations since those are always executed before the actual file that does the importing, and hence their contents are executed first.
mainmust be the first file that executes CHRONOLOGICALLY, not necessarily the topmost level file.
injectinto an HTML-ish index file an
indexfilename must be provided and this file will be scanned for a
<head>section. Once this is found the entire RevDeBug runtime script is inserted as the first script to run in this section.
local, the RevDeBug runtime is copied into the topmost level directory of the project or subproject as
__revdebug.jsand the individual project files
require()this file as needed. In this mode, as with
global, there is no main entry point and any of the project files may be executed first. For
globalthe behavior is different between
webprojects. For a
nodeproject the runtime is loaded via
require()but unlike a
import "../__revdebug"the runtime is assumed to be available either globally or as an istalled NPM module dependancy and is imported with an absolute path like
webproject the runtime is assumed to have been loaded as an individual script previously in an HTML file somewhere via something like
indexfilename then the script tag described will be automatically inserted into that file, otherwise you are responsible for loading the RevDeBug runtime somewhere yourself.
webproject you should have only one main project. But if your overall solution comprises of a node server and a web component for example then each should be their own subproject. The exception to this is when using WebWorkers or worker threads as those each get their own global scope when they are created and can thus host a completely different project from the code which created them.
typewhich may be inconvenient or impossible across subprojects.
revd --posta second time so that it can merge the two levels of source maps (one from the RevDeBug instrumentation pass and the second from the following compilation passes) into a single level of source maps pointing back to the original code.
postPathwhere the final output files live along with their source map files. if
postPathis not provided it will defult to the root directory of the project. Likewise you will need to specify
postFilesin the same way that
filesare specified. The
postFilesmay be a single output webpacked file or multiple files selected via wildcards. An example would be source
revd --postwill only process output files once, running it again after this will have no effect on files which have already been processed, but will reprocess any individual files which may have been recompiled.
__revdrecmethod on itself or in its prototype chain then this method will be called on the object during recording when the value of the object needs to be stringified. The object is assumed to be mutable so this call happens whenever the object is accessed in code which is being recorded. The call is of the form
obj.__revdrec(obj)so the actual object can be accessed as
thisor in case of arrow function as the first argument.
revdebug.str(obj)or more specifically
typeis one of the primitive names
object. Do not call a type function on an object which is not of that type, if you are not sure of the type then use
revdebug.block()you are marking this async context as well as any child async tasks it creates as isolated, meaning that if a
revdebug.exception()in this async context or its children it will only include the task and its children in the recording, not siblings or parent. When used in the APM portion of RevDeBug, this allows the isolation of a single given HTTP handler for example which may have an error from any number of other handlers which may be running concurrently.
block()functionality correctly you need to understand when the async task context changes in async code (it does not change for example upon initial entry into an
asyncfunction). That information is beyond the scope of this documentation but is available in the documentation for the Node
block = revdebug.block(), and when you are done with the part you want to isolate simply call
revdebug.async(). If you need to return synchronous control to some other async task without ending your isolation block yet (it will get control later), do the
async()before returning control to non-isolated code. Upon re-entry to your code which you want to isolate execute a
lastBlock = block.resync(), execute your code, and return to the previously executing context via
lastBlockhere is important because it allows recursive isolation of code blocks, otherwise the wrong previous context may be set if simply calling
async()(though this is ok after the initial
revdebug.block()because in this case we are sure we did not recurse into this block.
revdebug.block(), after which only code that is part of the block is shown. This is specified as either no parameter or a falsey paramenter to
revdebug.block(falsey)for complete isolation, or a truthy parameter for partial isolation.