Migrating to Profound.js 6 From Earlier Versions
Profound.js 5 and 6 are no longer supported. This page is retained for reference only and must not be used for a new installation or upgrade. For the current release, see Installation Process and Upgrade Process.
Overview
The major difference in the Profound.js 6 framework is the change from Fibers to Promises. Starting in Profound.js 6, all framework APIs return Promises and applications run in a top-down manner using the async and await keywords. Profound.js 6 is largely, but not entirely, backwards compatible with Profound.js 5.
Profound.js 5 Fix Pack 8 (5.8.0), released on 3/4/2022, is the last feature update for the Fibers-based Profound.js 5 framework. Profound Logic continued to support that release with fix updates for one year following the release of Profound.js 6. Profound.js 5 runs on Node.js 14, which is now end of life; new features are only available in Profound.js 6 and higher.
What is Changing?
Fibers replaced by Promises - All framework APIs return Promises, and applications use
async/awaitinstead of the Fibers addon;Newer Node.js support - Profound.js 6 runs on Node.js versions that the Fibers addon cannot support;
Built-in auto-restart removed - Automatic restart is now handled by external process management, as described below.
Why This Change? Why Promises?
Development on Profound.js started in late 2015, using Node.js 4. A key goal of the framework from the beginning was to simplify Node.js programming and eliminate the notorious Callback Hell. At that time there was no built-in way of coding asynchronous I/O in Node.js in a top-down manner.
The ECMAScript 6 standard that introduced Promises and async/await was finalized around the same time, but these features were not included in a Long-Term Support (LTS) version of Node.js until Node.js 8 in late 2017. The Fibers addon provided the needed capability and was used by other popular frameworks of the time, such as Meteor, so it was a logical choice.
Since then, Promises and async/await have become the standard for top-down asynchronous coding in Node.js. In April 2021, Node.js 16 was released with changes that break compatibility with the Fibers addon, and the Fibers author announced that the project had run its course. This change was therefore necessary to move Profound.js forward, support current and future Node.js versions, and stay in tune with the Node.js ecosystem.
What Does This Mean for My Existing Applications?
For the most part, existing applications written for Profound.js 5 continue to work with Profound.js 6. However, top-down programming with Promises is very different from Fibers, and it is not guaranteed that all existing applications will run as-is. Some applications may require minor modifications.
Do not upgrade a production Profound.js 5 instance before thoroughly testing the application with Profound.js 6 and making any needed modifications. Testing should be done in a separate Profound.js instance, so that production applications are not affected.
Modifications for Async/Await
Existing applications may need slight adjustments to add the async and await keywords where Profound.js module transformation is not able to do so automatically. For details, see Coding With Promises in Profound.js and the section Limitations of Module Transformation. The scenario given on that page is just one example; there may be other cases where module transformation is unable to add async/await, depending on how the application is coded.
Low Code Steps/Routines Converted to Code
Low Code applications that contain steps or routines converted to code need a slight adjustment if the converted steps or routines call other routines created by the Call Another Routine or Call Internal Routine plugins.
For example, the Call Another Routine plugin for Rich Display Files generates code like this:
The generated code needs to be adjusted to add await to the call:
Similarly, the Call Internal Routine plugin for low code modules generates code like this:
The code needs to be adjusted like this:
Conversion of start.js Files
When upgrading an existing Profound.js installation to version 6, the start.js file is automatically adjusted to work with Promises. For example, a file like this:
start.js - before the upgrade
#!/usr/bin/env node
var profoundjs = require("profoundjs");
var config = require("./config.js");
profoundjs.applyConfig(config);
var isWorker = profoundjs.server.listen();
if (isWorker) {
var express = profoundjs.server.express;
var app = profoundjs.server.app;
app.use(express.json());
}Is converted to this:
start.js - after the upgrade
#!/usr/bin/env node
async function startPJS() {
var profoundjs = require("profoundjs");
var config = require("./config.js");
profoundjs.applyConfig(config);
// server.listen() now returns a Promise, so it must be awaited.
var isWorker = await profoundjs.server.listen();
if (isWorker) {
var express = profoundjs.server.express;
var app = profoundjs.server.app;
app.use(express.json());
}
}
startPJS();The conversion process retains a copy of the original file as start.js.orig.TIME_STAMP. If you have customized start.js – for example for clustering (see Profound.js Clustering) – compare the converted file against your saved copy after the upgrade.
Removal of Built-in Auto-Restart
Prior versions of Profound.js included built-in functionality to automatically restart the server if it ended unexpectedly. This functionality was removed in Profound.js 6, and auto-restart should be handled through external process management:
IBM i - Use STRTCPSVR to manage your Profound.js servers, by selecting the option to set up STRTCPSVR configuration when installing Profound.js. Instances started with STRTCPSVR automatically restart if they end unexpectedly (see Starting and Ending Profound.js Instances);
Other platforms - Use PM2 for process management. PM2 includes functionality to automatically restart failed processes (see Autostart Profoundjs with PM2);
Docker/Kubernetes - Use features of Kubernetes, such as Pod auto restart, or of Docker, to automatically restart failed processes.