Comments (8)
Hi guys,
Happy to say you that (later is better than never) this will be handled in v6.
Liana.init
will return a promise that resolves after complete initialization.
from forest-express.
At Mon Bel Appart, we've found a reliable way to detect when the Liana has successfully initialized by hijacking different functions of its API. Here's how we've done it: https://github.com/monbelappart/monbelappart/blob/master/src/utils/Forest/hijackLiana.ts
from forest-express.
@atwoodjw @pangolingo @louisremi @davidbillamboz @tlubz thank you for your patience guys.
This contribution is available in a new 6.0.0-beta.0 beta version.
As a new premajor version, it contains breaking changes, so please take the time to read the upgrade note and test all your changes in a development environment before moving it to upper stages (staging, production,...)
π²π²π²
from forest-express.
We have been seeing the same issue in our implementation. Serverless/lambda really seems like the way to go for hosting these liana nanoservices. We are using forest-express-sequelize (through lumber-cli). Having a persistent server to proxy light admin traffic to a postgres database seems like overkill.
We have been forced to use a pretty clumsy workaround here, and wrap our AwsServerlessExpress.proxy(...)
call in a setTimeout(..., 200)
block.
It would be great if the ForestExpress.init
call set a promise on the returned object, or returned a promise, as the app returned is essentially not usable until the readdirAsync
promise chain settles.
Alternatively, exposing a "ready" callback in the opts could be useful (e.g. similar to #181).
from forest-express.
Hi,
I am also experiencing this.
I fixed it by disabling the auto schema sync : FOREST_DISABLE_AUTO_SCHEMA_APPLY = true
and also by implementing a very dirty hack to detect when the last request is made... here an exemple in TypeScript for Zeit Now.
import EventEmitter from 'events';
import forestExpressSequelize from 'forest-express-sequelize';
import forestExpressServiceIpWhitelist from 'forest-express/dist/services/ip-whitelist';
import { sequelize } from '../sequelize';
const app = forestExpressSequelize.init({
envSecret: process.env.FOREST_ENV_SECRET,
authSecret: process.env.FOREST_AUTH_SECRET,
sequelize,
});
const emitter = new EventEmitter();
let ipWhitelistDone = false;
const old = forestExpressServiceIpWhitelist.retrieve;
forestExpressServiceIpWhitelist.retrieve = async (
environmentSecret,
): Promise<void> => {
await old(environmentSecret);
ipWhitelistDone = true;
emitter.emit('ipWhitelistReady');
};
function ipWhitelistReady(): Promise<void> {
return new Promise((resolve): void => {
if (ipWhitelistDone) {
resolve();
return;
}
emitter.on('ipWhitelistReady', resolve);
});
}
app.use(async (req, res, next) => {
await ipWhitelistReady();
next();
});
export default app;
from forest-express.
We're still seeing this issue since @atwoodjw reported it last year. As he said, the problem is that weβre running on AWS Lambda and the Forest library doesnβt have time to boot before it tries to handle the request. This causes intermittent 404 errors because sometimes a new Lambda is spun up and sometimes an existing Lambda is reused (when reusing a Lambda the library has been initialized and responds successfully).
We need a way to await
the library initialization before asking it to handle the request.
from forest-express.
I want to use forest admin within aws lambda, but I cannot manage to add a production connection using the dashboard, I'm stuck in the "Set your environment variables" step. I tried debugging it, but I don't get any log output from forest or anything else. All I see is that the calss to /forest are answered with http 204 without any response.
I tried to use aws-serverless-express
to wrap forest-admin in a lambda function, my entrypoint looks like this:
'use strict';
const awsServerlessExpress = require('aws-serverless-express');
const app = require('./app');
const server = awsServerlessExpress.createServer(app);
exports.handler = (event, context) => { awsServerlessExpress.proxy(server, event, context) };
and I have not changed app.js
or anything else.
The serverless.yml is pretty simple as well:
service: myservice
provider:
name: aws
runtime: nodejs12.x
stage: production
region: eu-central-1
package:
exclude:
- '.env'
functions:
forestadmin:
handler: serverless.handler
events:
- httpApi: '*'
cors: true
environment:
FOREST_ENV_SECRET: '...'
FOREST_AUTH_SECRET: '...'
FOREST_DISABLE_AUTO_SCHEMA_APPLY: true
DATABASE_URL: 'postgres://...'
DATABASE_SCHEMA: public
DATABASE_SSL: false
NODE_ENV: production
from forest-express.
Hi @p0wl, I am not sure to understand how this is related to the issue.
If you need help to configure your aws lambda maybe you should ask for help here or create a dedicated issue.
from forest-express.
Related Issues (20)
- How to download remote file from URL in smart action?
- Server events subscription inhibits graceful shutdown HOT 5
- The automated release is failing π¨
- [+] Filters - Fields containing enum subfields are not available as filter on the UI HOT 8
- Small crash in forest-server-requester HOT 1
- forestadmin-schema.json created in the wrong directory HOT 1
- Allow setting 'isSortable' on Schema generated fields not only smart fields HOT 4
- SyntaxError: Cannot use import statement outside a module HOT 3
- Cannot login from FA.com: Cannot read property renderingId of undefined HOT 4
- Upload file through API HOT 1
- The automated release is failing π¨
- Yarn v2 breaks Schema creation HOT 2
- Allow external endpoint on smart action HOT 1
- defaultValue does not work in smart actions
- Intercom: dates are all in 1970 HOT 3
- The existence of a local in-memory cache object prevents Forest from running on clusters HOT 2
- Using a path in APPLICATION_URL fails HOT 1
- Add Fastify support HOT 1
- How to load the collections statically
- redirect_uri always return http://localhost:3310 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from forest-express.