pitaj

pitaj

Professional Web Developer. Main focus on Node.js and client-side Javascript.

Member Since 10 years ago

@NodeBB ,

Experience Points
17
follower
Lessons Completed
0
follow
Lessons Completed
25
stars
Best Reply Awards
37
repos

172 contributions in the last year

Pinned
⚡ ultralight javascript templating framework
⚡ Node.js based forum software built for the modern web
⚡ Fully-featured calendar plugin for NodeBB
⚡ Multiple progress bars based on the "progress" package
⚡ Download images from subreddits
⚡ A configurable generator for memorable passphrases
Activity
Oct
19
5 days ago
Activity icon
issue

pitaj issue NodeBB/NodeBB

pitaj
pitaj

Bi-weekly NodeBB digest

From the ACP options for digest in NodeBB, it would be quite nice to have the option to have a bi-weekly (every other week) digest. The reasons I would want this...

  • Weekly can be a bit overwhelming sometimes but monthly might not be quite enough
  • Fewer emails sent saves on my transactional email bill

Thanks for listening and keep of the good work!

Oct
17
1 week ago
Activity icon
issue

pitaj issue comment NodeBB/NodeBB

pitaj
pitaj

Transactionality / consistency

Hi, This is more of an architecture / understanding question than a bug report. Is it correct to say that NodeBB can find itself in an inconsistent state if it crashes? For example, it is possible that only a part of the housekeeping logic related to creating a post is executed. It can happen each time the application is killed in the middle of performing an action. This is due to the fact that there is no attempt to formulate the logic in a transactional/crash-proof manner. If so, are there any plans to change that? One good solution would be to run a type of periodic housekeeping activity that would run on a global mutex, locking out any other processing and making an atomic snapshot of the database. The database would have to support doing that efficiently. Like this, we could have the confidence that we are in a consistent state (by restoring a snapshot rather than using the "live" version after a crash) and the overhead would not necessarily be prohibitive, depending on the method used to snapshot the DB. What do you think?

pitaj
pitaj

(i.e. no more processing until the hook function finishes)

And while this is happening, nothing can write to the database, right? Stopping the world before every write operation sounds like a lot of overhead. How would you go about synchronizing this between multiple instances?

Activity icon
issue

pitaj issue comment NodeBB/NodeBB

pitaj
pitaj

Transactionality / consistency

Hi, This is more of an architecture / understanding question than a bug report. Is it correct to say that NodeBB can find itself in an inconsistent state if it crashes? For example, it is possible that only a part of the housekeeping logic related to creating a post is executed. It can happen each time the application is killed in the middle of performing an action. This is due to the fact that there is no attempt to formulate the logic in a transactional/crash-proof manner. If so, are there any plans to change that? One good solution would be to run a type of periodic housekeeping activity that would run on a global mutex, locking out any other processing and making an atomic snapshot of the database. The database would have to support doing that efficiently. Like this, we could have the confidence that we are in a consistent state (by restoring a snapshot rather than using the "live" version after a crash) and the overhead would not necessarily be prohibitive, depending on the method used to snapshot the DB. What do you think?

pitaj
pitaj

Do all of the databases support snapshots? How long do they take? Do they require pausing everything for the duration? It would be bad if the forum totally paused for seconds at a time.

Oct
16
1 week ago
pull request

pitaj pull request NodeBB/NodeBB

pitaj
pitaj

fix: clarify site settings urls vs config.json url

Common point of confusion

Activity icon
created branch

pitaj in NodeBB/NodeBB create branch pitaj-patch-2

createdAt 1 week ago
pull request

pitaj pull request NodeBB/NodeBB

pitaj
pitaj

fix: clarify SMTP enable toggle

Activity icon
created branch

pitaj in NodeBB/NodeBB create branch pitaj-patch-1

createdAt 1 week ago
Activity icon
issue

pitaj issue comment NodeBB/NodeBB

pitaj
pitaj

Email error: write epipe

Tried with nodebb 1.16 & 1.18, node v14, everything else works fine. But the email fails.

with default smtp setting, neither choose qq/126/163/… or use custom smtp server,it shows error 'write epipe'

Any ideas?

pitaj
pitaj

The toggle is "Use an external server to send emails".

Oct
15
1 week ago
Activity icon
issue

pitaj issue comment NodeBB/NodeBB

pitaj
pitaj

Email error: write epipe

Tried with nodebb 1.16 & 1.18, node v14, everything else works fine. But the email fails.

with default smtp setting, neither choose qq/126/163/… or use custom smtp server,it shows error 'write epipe'

Any ideas?

pitaj
pitaj

On the SMTP page, there's a rifle to enable the SMTP transport. That had to be enabled for the SMTP settings to be used.

Activity icon
issue

pitaj issue comment NodeBB/NodeBB

pitaj
pitaj

18.2 upgrade and no email accounts work anymore.

Have tried with Community but with no joy. My emails no longer work and pressing send on the contact page does nothing.

I have tried multiple email accounts and options with SMTP etc but i get nothing. The error log shows nothing but in events log i see a test email sent but the event shows the email as [email protected]

pitaj
pitaj

I don't know about that since they said it was working before the upgrade.

I do want to clear up one thing: the events log only logs an attempt to send the email. I recommend using the "test" template to test the emailer, as then you're guaranteed to get a pop-up client side with the error.

There are a few things you can check from here:

  • Try a different email provider (and tell us which you used and any resulting errors)
  • Try on a fresh install of 1.18.1 (the last version they said worked)
  • Try the iCloud settings in thunderbird or another 3rd party email client
Activity icon
issue

pitaj issue comment NodeBB/NodeBB

pitaj
pitaj

Email error: write epipe

Tried with nodebb 1.6 & 1.8, node v14, everything else works fine. But the email fails.

with default smtp setting, neither choose qq/126/163/… or use custom smtp server,it shows error 'write epipe'

Any ideas?

pitaj
pitaj

1.6 and 1.8

Do you mean 1.16 and 1.18?

Did you enable the SMTP transport?

Oct
14
1 week ago
Activity icon
issue

pitaj issue comment NodeBB/NodeBB

pitaj
pitaj

Transactionality / consistency

Hi, This is more of an architecture / understanding question than a bug report. Is it correct to say that NodeBB can find itself in an inconsistent state if it crashes? For example, it is possible that only a part of the housekeeping logic related to creating a post is executed. It can happen each time the application is killed in the middle of performing an action. This is due to the fact that there is no attempt to formulate the logic in a transactional/crash-proof manner. If so, are there any plans to change that? One good solution would be to run a type of periodic housekeeping activity that would run on a global mutex, locking out any other processing and making an atomic snapshot of the database. The database would have to support doing that efficiently. Like this, we could have the confidence that we are in a consistent state (by restoring a snapshot rather than using the "live" version after a crash) and the overhead would not necessarily be prohibitive, depending on the method used to snapshot the DB. What do you think?

pitaj
pitaj

Currently we use pretty much every database as if it's redis. This is a pain point and something that we want to move away from. If/when we do so, we should take that opportunity to use db transactions and such.

While your solution would probably work, I think a simpler better stopgap solution would be to create a cli cleanup command that runs only when the forum is stopped.

Oct
11
1 week ago
Activity icon
issue

pitaj issue comment NodeBB/NodeBB

pitaj
pitaj

Setup with env vars

Add a function to install.js that enables container users to do the whole setup non-interactively, as is customary with container deployments. This enables running the container on a clean database (currently only tested with postgresql, additional fields might be needed for others) by setting environment variables on the podman/docker run command line and have a functional NodeBB instance a few seconds later, without the interactive setup hassle.

Also modified Dockerfile to check whether alternative setup routine should be executed (if SETUP env var is non-empty).

pitaj
pitaj

Also I think it would be best if you did combine the two checkSetup functions or at least removed the duplicated setupVal and nconf database checks.

I also think it would be good to require the user to provide both password and password confirm as separate vars.

There are still a couple of comments lines 54 and 61 which should be removed.

And you should probably do setupVal = install.values like the existing fn does.

Activity icon
issue

pitaj issue comment NodeBB/NodeBB

pitaj
pitaj

Setup with env vars

Add a function to install.js that enables container users to do the whole setup non-interactively, as is customary with container deployments. This enables running the container on a clean database (currently only tested with postgresql, additional fields might be needed for others) by setting environment variables on the podman/docker run command line and have a functional NodeBB instance a few seconds later, without the interactive setup hassle.

Also modified Dockerfile to check whether alternative setup routine should be executed (if SETUP env var is non-empty).

pitaj
pitaj

The test failures are definitely caused by your changes. The previous commit https://github.com/NodeBB/NodeBB/commit/8af54255d88c76cc27747688d5e09229a2692d5d passed tests.

Oct
9
2 weeks ago
Activity icon
issue

pitaj issue comment NodeBB/NodeBB

pitaj
pitaj

refactor: var to const and let

pitaj
pitaj

Should probably change .eslintrc to match

Oct
5
2 weeks ago
open pull request

pitaj wants to merge NodeBB/NodeBB

pitaj
pitaj

Setup with env vars

Add a function to install.js that enables container users to do the whole setup non-interactively, as is customary with container deployments. This enables running the container on a clean database (currently only tested with postgresql, additional fields might be needed for others) by setting environment variables on the podman/docker run command line and have a functional NodeBB instance a few seconds later, without the interactive setup hassle.

Also modified Dockerfile to check whether alternative setup routine should be executed (if SETUP env var is non-empty).

pitaj
pitaj

You can use ([key, val]) => and I suggest you give them better names like envVar, setupKey or something.

pull request

pitaj merge to NodeBB/NodeBB

pitaj
pitaj

Setup with env vars

Add a function to install.js that enables container users to do the whole setup non-interactively, as is customary with container deployments. This enables running the container on a clean database (currently only tested with postgresql, additional fields might be needed for others) by setting environment variables on the podman/docker run command line and have a functional NodeBB instance a few seconds later, without the interactive setup hassle.

Also modified Dockerfile to check whether alternative setup routine should be executed (if SETUP env var is non-empty).

open pull request

pitaj wants to merge NodeBB/NodeBB

pitaj
pitaj

Setup with env vars

Add a function to install.js that enables container users to do the whole setup non-interactively, as is customary with container deployments. This enables running the container on a clean database (currently only tested with postgresql, additional fields might be needed for others) by setting environment variables on the podman/docker run command line and have a functional NodeBB instance a few seconds later, without the interactive setup hassle.

Also modified Dockerfile to check whether alternative setup routine should be executed (if SETUP env var is non-empty).

pitaj
pitaj

Well how about you make a few changes fire improvement and then I'll see how it looks from there:

  • Object.entries instead of Object.keys
  • Use .startsWith instead of regexs
  • const setupVal = {};
  • use process.env instead of nconf.env.get
pull request

pitaj merge to NodeBB/NodeBB

pitaj
pitaj

Setup with env vars

Add a function to install.js that enables container users to do the whole setup non-interactively, as is customary with container deployments. This enables running the container on a clean database (currently only tested with postgresql, additional fields might be needed for others) by setting environment variables on the podman/docker run command line and have a functional NodeBB instance a few seconds later, without the interactive setup hassle.

Also modified Dockerfile to check whether alternative setup routine should be executed (if SETUP env var is non-empty).

Activity icon
issue

pitaj issue comment NodeBB/NodeBB

pitaj
pitaj

Setup with env vars

Add a function to install.js that enables container users to do the whole setup non-interactively, as is customary with container deployments. This enables running the container on a clean database (currently only tested with postgresql, additional fields might be needed for others) by setting environment variables on the podman/docker run command line and have a functional NodeBB instance a few seconds later, without the interactive setup hassle.

Also modified Dockerfile to check whether alternative setup routine should be executed (if SETUP env var is non-empty).

pitaj
pitaj

You haven't actually fixed lint issues. I don't know why our tests aren't executing but I recommend running the linter locally and fixing all the issues based on the feedback there.

pull request

pitaj merge to NodeBB/NodeBB

pitaj
pitaj

Setup with env vars

Add a function to install.js that enables container users to do the whole setup non-interactively, as is customary with container deployments. This enables running the container on a clean database (currently only tested with postgresql, additional fields might be needed for others) by setting environment variables on the podman/docker run command line and have a functional NodeBB instance a few seconds later, without the interactive setup hassle.

Also modified Dockerfile to check whether alternative setup routine should be executed (if SETUP env var is non-empty).

open pull request

pitaj wants to merge NodeBB/NodeBB

pitaj
pitaj

Setup with env vars

Add a function to install.js that enables container users to do the whole setup non-interactively, as is customary with container deployments. This enables running the container on a clean database (currently only tested with postgresql, additional fields might be needed for others) by setting environment variables on the podman/docker run command line and have a functional NodeBB instance a few seconds later, without the interactive setup hassle.

Also modified Dockerfile to check whether alternative setup routine should be executed (if SETUP env var is non-empty).

pitaj
pitaj

Honestly this looks a little over complicated. I don't think it's really helping by using a regex nconf etc here. I think it would be better to just do:

const setupVal = {
  'admin:username': process.env['NODEBB_ADMIN_USERNAME'],
  'port': process.env['NODEBB_PORT'],
  ...
};
Activity icon
issue

pitaj issue comment NodeBB/NodeBB

pitaj
pitaj

Setup with env vars

Add a function to install.js that enables container users to do the whole setup non-interactively, as is customary with container deployments. This enables running the container on a clean database (currently only tested with postgresql, additional fields might be needed for others) by setting environment variables on the podman/docker run command line and have a functional NodeBB instance a few seconds later, without the interactive setup hassle.

Also modified Dockerfile to check whether alternative setup routine should be executed (if SETUP env var is non-empty).

pitaj
pitaj

Don't worry about changing the test setups to use the env vars. Your changes should be backwards compatible with how we currently do it.

Sep
28
3 weeks ago
Activity icon
issue

pitaj issue comment tc39/proposal-do-expressions

pitaj
pitaj

Completion value is complex 10 times harder when `break` is involved

As many issues have pointed out, completion values are hard to find out. Although the status quo disallows for loop, it's still not enough.

I was implementing the type checker for the do expression. It's an intuitive idea that I only need to recursively check the last statement and check every branch. But when break comes in, it becomes a mess.

expr = do {
a: {
    for (const a of [1, 2]) {
        if (a === 2) { a; break a; }
    }
    3
}
}

For example, the complete value of the expression above is 2. It needs much more work to analyze them correctly (not only for the type checker but also for developers).

Is it possible to ban LabelledStatement and SwitchStatement as the last statement?

SwitchStatement is useful before we have pattern matching, instead of ban it as a whole, maybe we can introduce a "well-formed" version like what we did for if (the last if must have else branch).

  • Each clause either be a fallthrough case with no statement inside
  • Either be a clause that only has an exact 1 break statement and that statement must be the last statement.
  • Must have a default clause.
pitaj
pitaj

@Jack-Works could you give an example why your first two switch restrictions are necessary? I'd think requiring a default case would be enough.

Activity icon
issue

pitaj issue comment tc39/proposal-do-expressions

pitaj
pitaj

Completion value is complex 10 times harder when `break` is involved

As many issues have pointed out, completion values are hard to find out. Although the status quo disallows for loop, it's still not enough.

I was implementing the type checker for the do expression. It's an intuitive idea that I only need to recursively check the last statement and check every branch. But when break comes in, it becomes a mess.

expr = do {
a: {
    for (const a of [1, 2]) {
        if (a === 2) { a; break a; }
    }
    3
}
}

For example, the complete value of the expression above is 2. It needs much more work to analyze them correctly (not only for the type checker but also for developers).

Is it possible to ban LabelledStatement and SwitchStatement as the last statement?

SwitchStatement is useful before we have pattern matching, instead of ban it as a whole, maybe we can introduce a "well-formed" version like what we did for if (the last if must have else branch).

  • Each clause either be a fallthrough case with no statement inside
  • Either be a clause that only has an exact 1 break statement and that statement must be the last statement.
  • Must have a default clause.
pitaj
pitaj

I'm reluctant to introduce a restriction which prohibits users from using a feature they probably weren't even aware of, because it's not obvious that would benefit anyone.

On the other hand, adding restrictions later is not really possible, whereas it is possible to loosen restrictions later.

Sep
26
4 weeks ago
pull request

pitaj pull request NodeBB/NodeBB

pitaj
pitaj

Add more chat hooks, replace toobig.jpg

Fixes #9813

Chat hooks are for global chat plugin improvements

push

pitaj push NodeBB/NodeBB

pitaj
pitaj

feat: more hooks for messaging

for use in global chat plugin

pitaj
pitaj

fix: replace toobig.jpg

toobig.png is a real 10000x10000 image

commit sha: cd4f6a65ab30c68934ebc7bc98b6a96191806aa4

push time in 3 weeks ago
Activity icon
created branch

pitaj in NodeBB/NodeBB create branch some-fixes

createdAt 3 weeks ago
Sep
25
4 weeks ago
Activity icon
issue

pitaj issue NodeBB/NodeBB

pitaj
pitaj

test/files/toobig.jpg is flagged as a trojan malware by 15 security vendors

The JPG file NodeBB/test/files/toobig.jpg is flagged as a trojan malware by 15 security vendors. Here is the detailed report:

https://www.virustotal.com/gui/file/d4684cddd1d85ef0f0e184c9a0c500e45c2f49cf4b22acd7a1c9ee1f5dfa9fa9/details

I assume I'm not the only one getting this. Is there anything we could do to fix this?

Thanks.

  • NodeBB version: All latest NodeBB stable versions
  • Exact steps to cause this issue: Run any major antivirus/malware scanner on the folder where NodeBB is installed.
  • What you expected: All files in NodeBB package to be clean of any virus/malware.
  • What happened instead: Microsoft Defender app detected that the file NodeBB/test/files/toobig.jpg is malicious.
Previous